aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/fs/lstat.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
commitfc8c5fdce62fb229202659408798a7b6c98f6e8b (patch)
tree7554f80e50de4af6fd255afa7c21bcdd58a7af34 /cli/internal/fs/lstat.go
parentdd84b9d64fb98746a230cd24233ff50a562c39c9 (diff)
downloadHydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz
HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip
Diffstat (limited to 'cli/internal/fs/lstat.go')
-rw-r--r--cli/internal/fs/lstat.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/cli/internal/fs/lstat.go b/cli/internal/fs/lstat.go
deleted file mode 100644
index eff0810..0000000
--- a/cli/internal/fs/lstat.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package fs
-
-import (
- "io/fs"
- "os"
-
- "github.com/vercel/turbo/cli/internal/turbopath"
-)
-
-// LstatCachedFile maintains a cache of file info, mode and type for the given Path
-type LstatCachedFile struct {
- Path turbopath.AbsoluteSystemPath
- fileInfo fs.FileInfo
- fileMode *fs.FileMode
- fileType *fs.FileMode
-}
-
-// GetInfo returns, and caches the file info for the LstatCachedFile.Path
-func (file *LstatCachedFile) GetInfo() (fs.FileInfo, error) {
- if file.fileInfo != nil {
- return file.fileInfo, nil
- }
-
- err := file.lstat()
- if err != nil {
- return nil, err
- }
-
- return file.fileInfo, nil
-}
-
-// GetMode returns, and caches the file mode for the LstatCachedFile.Path
-func (file *LstatCachedFile) GetMode() (fs.FileMode, error) {
- if file.fileMode != nil {
- return *file.fileMode, nil
- }
-
- err := file.lstat()
- if err != nil {
- return 0, err
- }
-
- return *file.fileMode, nil
-}
-
-// GetType returns, and caches the type bits of (FileMode & os.ModeType) for the LstatCachedFile.Path
-func (file *LstatCachedFile) GetType() (fs.FileMode, error) {
- if file.fileType != nil {
- return *file.fileType, nil
- }
-
- err := file.lstat()
- if err != nil {
- return 0, err
- }
-
- return *file.fileType, nil
-}
-
-func (file *LstatCachedFile) lstat() error {
- fileInfo, err := file.Path.Lstat()
- if err != nil {
- return err
- }
-
- fileMode := fileInfo.Mode()
- fileModeType := fileMode & os.ModeType
-
- file.fileInfo = fileInfo
- file.fileMode = &fileMode
- file.fileType = &fileModeType
-
- return nil
-}