// GetBinaryName checks if useBinary is in binDir and returns it. If
// useBinary is empty it returns a binary name if there is only one
// such in binDir. Otherwise it returns an error.
351533
func GetBinaryName(binDir, useBinary string) (string, error) {
	fi, err := ioutil.ReadDir(binDir)
	if err != nil {
		return "", err
	}

	switch {
	case len(fi) < 1:
		return "", fmt.Errorf("No binaries found in %q", binDir)
	case len(fi) == 1:
		name := fi[0].Name()
		if useBinary != "" && name != useBinary {
			return "", fmt.Errorf("No such binary found in %q: %q. There is only %q", binDir, useBinary, name)
		}
		Debug("found binary: ", name)
		return name, nil
	case len(fi) > 1:
		names := []string{}
		for _, v := range fi {
			names = append(names, v.Name())
		}
		if useBinary == "" {
			return "", fmt.Errorf("Found multiple binaries in %q, but no specific binary is preferred. Please specify which binary to pick up. Following binaries are available: %q", binDir, strings.Join(names, `", "`))
		}
		for _, v := range names {
			if v == useBinary {
				return v, nil
			}
		}
		return "", fmt.Errorf("No such binary found in %q: %q. There are following binaries available: %q", binDir, useBinary, strings.Join(names, `", "`))
	}
	panic("Reaching this point shouldn't be possible.")
}
35260
func (n NetID) MarshalBinary() ([]byte, error) {
	out := make([]byte, len(n))

	// little endian
	for i, v := range n {
		out[len(n)-1-i] = v
	}

	return out, nil
}
1122835
func (meta *Meta) ReadBinary(r io.Reader) error {
	return binary.Read(r, byteorder.Native, meta)
}
935048
func (o *GetAuthCallbackOKBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}
332367
func (r *RenameFileRequest) MarshalBinary() ([]byte, error) {
	var fields []string

	add := func(s string, l *uint32) {
		*l = uint32(len(s)) // NOTE: NULL byte is not included in the length fields on the wire
		fields = append(fields, s)
	}

	add(r.OldPathName, &r.Body.OldPathNameLength)
	add(r.NewPathName, &r.Body.NewPathNameLength)

	buf := new(bytes.Buffer)

	_ = binary.Write(buf, binary.LittleEndian, &r.Body)

	for _, val := range fields {
		_, _ = buf.Write([]byte(val))
		_ = buf.WriteByte(0)
	}

	return buf.Bytes(), nil
}
249951
func (p DLChannelAnsPayload) MarshalBinary() ([]byte, error) {
	var b byte
	if p.ChannelFrequencyOK {
		b = b ^ 1
	}
	if p.UplinkFrequencyExists {
		b = b ^ (1 << 1)
	}
	return []byte{b}, nil
}
225551
func (brewDep BrewDepModel) GetBinaryName() string {
	if brewDep.BinName != "" {
		return brewDep.BinName
	}
	return brewDep.Name
}
45639
func (m *APIResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
190150
func (r Redundancy) MarshalBinary() ([]byte, error) {
	b := make([]byte, 1)
	if r.NbRep > 15 {
		return b, errors.New("lorawan: max value of NbRep is 15")
	}
	if r.ChMaskCntl > 7 {
		return b, errors.New("lorawan: max value of ChMaskCntl is 7")
	}
	b[0] = r.NbRep ^ (r.ChMaskCntl << 4)
	return b, nil
}
123233
func (m *Error) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
463537
func (p *Params) generateBinaryName() string {
	rand.Seed(time.Now().UnixNano())
	randName := rand.Int31n(999999)
	packageName := strings.Replace(p.packagePath(), "/", "-", -1)

	return fmt.Sprintf("%s-%s-%d", generateBinaryPrefix(), packageName, randName)
}
846647
func (m *StatusResponseProxy) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
303381
func (r *RequestOpenV3) MarshalBinary() ([]byte, error) {
	return MarshalBinary(&r.Mask, &r.OpenMode, &r.OpenFlags,
		&r.SpecialPerms, &r.OwnerPerms, &r.GroupPerms, &r.OtherPerms,
		&r.AttrFlags, &r.AllocationSize, &r.DesiredAccess, &r.ShareAccess,
		&r.DesiredLock, &r.Reserved1, &r.Reserved2, &r.FileName)
}
1215080
func (m *SwaggerOAuthTokenResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
460747
func (m *RequestHandlerResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
23582
func (h TLFReaderKeyBundleID) MarshalBinary() (data []byte, err error) {
	return h.h.MarshalBinary()
}
734957
func (r *RemoteIdentifier) MarshalBinary() ([]byte, error) {
	// 4 bytes: EnterpriseNumber
	// N bytes: RemoteId
	b := buffer.New(nil)
	b.Write32(r.EnterpriseNumber)
	b.WriteBytes(r.RemoteID)
	return b.Data(), nil
}