aboutsummaryrefslogtreecommitdiff
path: root/filesystem.go
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem.go')
-rw-r--r--filesystem.go89
1 files changed, 0 insertions, 89 deletions
diff --git a/filesystem.go b/filesystem.go
deleted file mode 100644
index f744714..0000000
--- a/filesystem.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package pkgtools
-
-import (
- "io/fs"
- "math"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
-)
-
-const maxLockWait = 10 * time.Second
-
-func CopyFile(dst string, src string) error {
- return ErrNotImplemented
-}
-
-func HumanReadableSize(size int64) string {
- suffixes := []string{
- "B",
- "K",
- "M",
- "G",
- "T",
- }
-
- base := math.Log(float64(size)) / math.Log(1024)
- newSize := math.Ceil(math.Pow(1024, base-math.Floor(base))*10) / 10
- newSuffix := suffixes[int(math.Floor(base))]
- ret := strconv.FormatFloat(newSize, 'f', -1, 64) + newSuffix
- return ret
-}
-
-func IsExist(path string) (bool, error) {
- _, err := os.Stat(path)
- if os.IsNotExist(err) {
- return false, nil
- }
- if err != nil {
- return false, err
- }
- return true, nil
-}
-
-func IsFile(path string) (bool, error) {
- info, err := os.Stat(path)
- if err != nil {
- return false, err
- }
- return info.Mode().IsRegular(), nil
-}
-
-func IsDir(path string) (bool, error) {
- info, err := os.Stat(path)
- if err != nil {
- return false, err
- }
- return info.IsDir(), nil
-}
-
-func IsParentDir(parent, sub string) (bool, error) {
- up := ".." + string(os.PathSeparator)
-
- rel, err := filepath.Rel(parent, sub)
- if err != nil {
- return false, err
- }
- if !strings.HasPrefix(rel, up) && rel != ".." {
- return true, nil
- }
- return false, nil
-}
-
-func IsSymlink(path string) (bool, error) {
- info, err := os.Stat(path)
- if err != nil {
- return false, err
- }
- return info.Mode() == fs.ModeSymlink, nil
-}
-
-func FileSize(fp string) (int64, error) {
- info, err := os.Stat(fp)
- if err != nil {
- return 0, err
- }
- return info.Size(), nil
-}