diff options
Diffstat (limited to 'vendor/codeberg.org/gruf/go-store/storage/fs.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-store/storage/fs.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/vendor/codeberg.org/gruf/go-store/storage/fs.go b/vendor/codeberg.org/gruf/go-store/storage/fs.go index b1c3560d2..b4729b041 100644 --- a/vendor/codeberg.org/gruf/go-store/storage/fs.go +++ b/vendor/codeberg.org/gruf/go-store/storage/fs.go @@ -9,8 +9,8 @@ import ( const ( // default file permission bits - defaultDirPerms = 0755 - defaultFilePerms = 0644 + defaultDirPerms = 0o755 + defaultFilePerms = 0o644 // default file open flags defaultFileROFlags = syscall.O_RDONLY @@ -22,7 +22,7 @@ const ( // These functions are for opening storage files, // not necessarily for e.g. initial setup (OpenFile) -// open should not be called directly +// open should not be called directly. func open(path string, flags int) (*os.File, error) { var fd int err := util.RetryOnEINTR(func() (err error) { @@ -35,7 +35,7 @@ func open(path string, flags int) (*os.File, error) { return os.NewFile(uintptr(fd), path), nil } -// stat checks for a file on disk +// stat checks for a file on disk. func stat(path string) (bool, error) { var stat syscall.Stat_t err := util.RetryOnEINTR(func() error { @@ -49,3 +49,17 @@ func stat(path string) (bool, error) { } return true, nil } + +// unlink removes a file (not dir!) on disk. +func unlink(path string) error { + return util.RetryOnEINTR(func() error { + return syscall.Unlink(path) + }) +} + +// rmdir removes a dir (not file!) on disk. +func rmdir(path string) error { + return util.RetryOnEINTR(func() error { + return syscall.Rmdir(path) + }) +} |