MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / getFiles

Method getFiles

agent/utils/files/fileinfo.go:334–364  ·  view source on GitHub ↗
(option FileOption)

Source from the content-addressed store, hash-verified

332}
333
334func (f *FileInfo) getFiles(option FileOption) ([]FileSearchInfo, error) {
335 infos, err := os.ReadDir(f.Path)
336 if err != nil {
337 return nil, err
338 }
339 var (
340 dirs []FileSearchInfo
341 fileList []FileSearchInfo
342 )
343
344 for _, file := range infos {
345 fileInfo, err := file.Info()
346 if err != nil {
347 continue
348 }
349 info := FileSearchInfo{
350 Path: f.Path,
351 FileInfo: fileInfo,
352 }
353 if file.IsDir() {
354 dirs = append(dirs, info)
355 } else {
356 fileList = append(fileList, info)
357 }
358 }
359
360 sortFileList(dirs, option.SortBy, option.SortOrder)
361 sortFileList(fileList, option.SortBy, option.SortOrder)
362
363 return append(dirs, fileList...), nil
364}
365
366func (f *FileInfo) processFiles(files []FileSearchInfo, option FileOption) ([]*FileInfo, error) {
367 var items []*FileInfo

Callers 1

listChildrenMethod · 0.95

Calls 3

ReadDirMethod · 0.80
IsDirMethod · 0.80
sortFileListFunction · 0.70

Tested by

no test coverage detected