// NumberOfFileHandles returns the number of open file handles for
// this filesystem.
482098
func (fi *FileInfo) NumberOfFileHandles() uint32 {
	return fsTableGetFileCount(uint32(fi.ptr.DokanOptions.GlobalContext))
}
1198256
func SendStaticFileHandler(filename string) http.Handler {
	staticHandler := StaticFileHandler(filename)
	_, sendfilename := filepath.Split(filename)
	h := http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		staticHandler.ServeHTTP(res, req)
		res.Header().Set(contentDisposition, "attachment;filename="+sendfilename)
	})

	return h
}
366488
func Handlers(handlers ...Handler) HandlerFunc {
	return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
		var children []ocispec.Descriptor
		for _, handler := range handlers {
			ch, err := handler.Handle(ctx, desc)
			if err != nil {
				if errors.Cause(err) == ErrStopHandler {
					break
				}
				return nil, err
			}

			children = append(children, ch...)
		}

		return children, nil
	}
}
644051
func StaticFileHandler(filename string) http.Handler {
	fcontents, err := ioutil.ReadFile(filename) // cache the contents of the file, this is the difference from net/http's impl, this is used only for static files, like favicons, css and so on
	if err != nil {
		return errorHandler(http.StatusBadRequest)
	}
	return StaticContentHandler(fcontents, TypeByExtension(filename))
}
84559
func (files FileInfos) AstFiles() []*ast.File {
	astFiles := make([]*ast.File, len(files))
	for i, file := range files {
		astFiles[i] = file.AstFile()
	}
	return astFiles
}
904966
func NumProcs() uint32 {
	var sysinfo systeminfo
	syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
	return sysinfo.dwNumberOfProcessors
}
206350
func makeDatabaseHandles() int {
	limit, err := fdlimit.Maximum()
	if err != nil {
		Fatalf("Failed to retrieve file descriptor allowance: %v", err)
	}
	raised, err := fdlimit.Raise(uint64(limit))
	if err != nil {
		Fatalf("Failed to raise file descriptor allowance: %v", err)
	}
	return int(raised / 2) // Leave half for networking and other stuff
}
398581
func WithFileHandler(h filesource.FileHandler) FileOption {
	return func(options *FileOptions) {
		options.Handler = h
	}

}
1356740
func (fs *FileSet) IndexFiles() []*IndexFile {
	var a []*IndexFile
	for _, f := range fs.files {
		if f, ok := f.(*IndexFile); ok {
			a = append(a, f)
		}
	}
	return a
}
800659
func (ss *StaticServer) FileHandler(fileName string) http.Handler {
	id := fileName
	fileName = ss.resolve(fileName)
	return &staticHandler{
		ss:   ss,
		id:   func(_ string) string { return id },
		open: func(_ string) (io.ReadCloser, int64, string, error) { return ss.openFile(fileName) },
	}
}
303736
func GetHandleInfo(in interface{}) (uintptr, bool) {
	switch t := in.(type) {
	case *ansiReader:
		return t.Fd(), true
	case *ansiWriter:
		return t.Fd(), true
	}

	var inFd uintptr
	var isTerminal bool

	if file, ok := in.(*os.File); ok {
		inFd = file.Fd()
		isTerminal = IsConsole(inFd)
	}
	return inFd, isTerminal
}
286389
func SeekRangeNumbers(expr string, fn func(int) bool) {
	expa := strings.SplitN(expr, ":", 2)
	step := 1
	switch len(expa) {
	case 2:
		if i, e := strconv.Atoi(strings.TrimSpace(expa[1])); e == nil {
			step = i
		}
		fallthrough
	case 1:
		for _, exp := range strings.Split(strings.TrimSpace(expa[0]), `,`) {
			exp = strings.TrimSpace(exp)
			if len(exp) == 0 {
				continue
			}
			expb := strings.SplitN(exp, `-`, 2)
			var minN, maxN int
			switch len(expb) {
			case 2:
				maxN, _ = strconv.Atoi(strings.TrimSpace(expb[1]))
				fallthrough
			case 1:
				minN, _ = strconv.Atoi(strings.TrimSpace(expb[0]))
			}
			if maxN == 0 {
				if !fn(minN) {
					return
				}
				continue
			}
			for ; minN <= maxN; minN += step {
				if !fn(minN) {
					return
				}
			}
		}
	}
}
847500
func (f Index) CountFrom(start Item) (count int, err error) {
	startKey, err := f.encodeKeyFunc(start)
	if err != nil {
		return 0, err
	}
	it := f.db.NewIterator()
	defer it.Release()

	for ok := it.Seek(startKey); ok; ok = it.Next() {
		key := it.Key()
		if key[0] != f.prefix[0] {
			break
		}
		count++
	}
	return count, it.Error()
}
413754
func WithHandle500(fn func(rw http.ResponseWriter, req *http.Request, err error)) option {
	return func(m *Module) {
		m.handle500 = fn
	}
}
13324
func (b *BackupEngineInfo) GetNumFiles(index int) int32 {
	return int32(C.rocksdb_backup_engine_info_number_files(b.c, C.int(index)))
}
807612
func (fsh *Handler) GetFileNames(paths []string) (files []string, err error) {
	for _, path := range paths {
		err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
			if err != nil {
				return err
			}
			if info == nil || info.IsDir() {
				return nil
			}
			files = append(files, path)
			return nil
		})
		if err != nil {
			err = errors.Errorf("failed to traverse through %s: %v", path, err)
		}
	}
	return files, err
}
169137
func GetHandleFromFolderNameAndType(
	ctx context.Context, kbpki KBPKI, idGetter tlfhandle.IDGetter,
	syncGetter syncedTlfGetterSetter, tlfName string,
	t tlf.Type) (*tlfhandle.Handle, error) {
	for {
		tlfHandle, err := tlfhandle.ParseHandle(
			ctx, kbpki, idGetter, syncGetter, tlfName, t)
		switch e := errors.Cause(err).(type) {
		case idutil.TlfNameNotCanonical:
			tlfName = e.NameToTry
		case nil:
			return tlfHandle, nil
		default:
			return nil, err
		}
	}
}