(files []FileSearchInfo, option FileOption)
| 364 | } |
| 365 | |
| 366 | func (f *FileInfo) processFiles(files []FileSearchInfo, option FileOption) ([]*FileInfo, error) { |
| 367 | var items []*FileInfo |
| 368 | |
| 369 | for _, df := range files { |
| 370 | if shouldSkipFile(df, option) { |
| 371 | continue |
| 372 | } |
| 373 | |
| 374 | name, fPath := f.getFilePathAndName(option, df) |
| 375 | |
| 376 | if !option.ShowHidden && IsHidden(name) { |
| 377 | continue |
| 378 | } |
| 379 | f.ItemTotal++ |
| 380 | |
| 381 | isSymlink, isInvalidLink := f.checkSymlink(df) |
| 382 | |
| 383 | file := &FileInfo{ |
| 384 | Fs: f.Fs, |
| 385 | Name: name, |
| 386 | Size: df.Size(), |
| 387 | ModTime: df.ModTime(), |
| 388 | FileMode: df.Mode(), |
| 389 | IsDir: df.IsDir(), |
| 390 | IsSymlink: isSymlink, |
| 391 | IsHidden: IsHidden(fPath), |
| 392 | Extension: filepath.Ext(name), |
| 393 | Path: fPath, |
| 394 | Mode: fmt.Sprintf("%04o", df.Mode().Perm()), |
| 395 | User: GetUsername(df.Sys().(*syscall.Stat_t).Uid), |
| 396 | Group: GetGroup(df.Sys().(*syscall.Stat_t).Gid), |
| 397 | Uid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Uid), 10), |
| 398 | Gid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Gid), 10), |
| 399 | } |
| 400 | favoriteRepo := repo.NewIFavoriteRepo() |
| 401 | favorite, _ := favoriteRepo.GetFirst(favoriteRepo.WithByPath(fPath)) |
| 402 | if favorite.ID > 0 { |
| 403 | file.FavoriteID = favorite.ID |
| 404 | } |
| 405 | if isSymlink { |
| 406 | linkPath := GetSymlink(fPath) |
| 407 | if !filepath.IsAbs(linkPath) { |
| 408 | dir := filepath.Dir(fPath) |
| 409 | var err error |
| 410 | linkPath, err = filepath.Abs(filepath.Join(dir, linkPath)) |
| 411 | if err != nil { |
| 412 | return nil, err |
| 413 | } |
| 414 | } |
| 415 | file.LinkPath = linkPath |
| 416 | targetInfo, err := file.Fs.Stat(linkPath) |
| 417 | if err != nil { |
| 418 | file.IsDir = false |
| 419 | file.Mode = "-" |
| 420 | file.User = "-" |
| 421 | file.Group = "-" |
| 422 | } else { |
| 423 | file.IsDir = targetInfo.IsDir() |
no test coverage detected