mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/fs: remove unused IsEmptyDir()
This function became unused after the commit 43b24164ef
The unused function has been found with deadode tool - https://go.dev/blog/deadcode
This commit is contained in:
parent
8bc87acfb9
commit
329bd244d2
18
lib/fs/fs.go
18
lib/fs/fs.go
@ -190,24 +190,6 @@ func mustSyncParentDirIfExists(path string) {
|
|||||||
MustSyncPath(parentDirPath)
|
MustSyncPath(parentDirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEmptyDir returns true if path points to empty directory.
|
|
||||||
func IsEmptyDir(path string) bool {
|
|
||||||
// See https://stackoverflow.com/a/30708914/274937
|
|
||||||
f, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
logger.Panicf("FATAL: cannot open dir: %s", err)
|
|
||||||
}
|
|
||||||
_, err = f.Readdirnames(1)
|
|
||||||
MustClose(f)
|
|
||||||
if err != nil {
|
|
||||||
if err == io.EOF {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
logger.Panicf("FATAL: unexpected error when reading directory %q: %s", path, err)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// MustRemoveDirAtomic removes the given dir atomically.
|
// MustRemoveDirAtomic removes the given dir atomically.
|
||||||
//
|
//
|
||||||
// It uses the following algorithm:
|
// It uses the following algorithm:
|
||||||
|
Loading…
Reference in New Issue
Block a user