diff --git a/ios/fsutils_test.go b/ios/fsutils_test.go index 840f548c67..ab14853d6a 100644 --- a/ios/fsutils_test.go +++ b/ios/fsutils_test.go @@ -44,33 +44,6 @@ func TestDirSize(t *testing.T) { } } -func TestDirFiles(t *testing.T) { - name, err := os.MkdirTemp("/tmp", t.Name()) - if err != nil { - t.Error(err) - return - } - defer os.RemoveAll(name) - - checkFileCount(t, name, 0) - - subdir, err := os.MkdirTemp(name, "") - if err != nil { - t.Error(err) - return - } - - checkFileCount(t, name, 0) - - size := mkFile(t, name, "f1.txt") - checkFileCount(t, name, 1) - - size += mkFile(t, subdir, "f2.txt") - size += mkFile(t, subdir, "f3.txt") - checkFileCount(t, name, 3) - checkFileSizes(t, name, size) -} - func mkFile(t *testing.T, dir, fname string) (written int) { k := mono.NanoTime() & 0xff f, err := os.Create(path.Join(dir, fname)) @@ -89,23 +62,3 @@ func mkFile(t *testing.T, dir, fname string) (written int) { } return } - -func checkFileCount(t *testing.T, dir string, expcnt int) { - fileCount, err := ios.DirFileCount(dir) - if err != nil { - t.Error(err) - } - if fileCount != expcnt { - t.Fatalf("Expected %d files, got %d", expcnt, fileCount) - } -} - -func checkFileSizes(t *testing.T, dir string, expsize int) { - size, err := ios.DirSumFileSizes(dir) - if err != nil { - t.Error(err) - } - if size != uint64(expsize) { - t.Fatalf("Expected %d size, got %d", expsize, size) - } -} diff --git a/ios/fsutils_unix.go b/ios/fsutils_unix.go index d628304b23..d9d5a0a78d 100644 --- a/ios/fsutils_unix.go +++ b/ios/fsutils_unix.go @@ -65,29 +65,3 @@ func _parseTotal(s string) (size int64) { } return } - -func DirFileCount(dirPath string) (int, error) { - cmd := fmt.Sprintf("find %s -type f | wc -l", dirPath) - outputBytes, err := exec.Command("/bin/sh", "-c", cmd).Output() - out := string(outputBytes) - if err != nil || out == "" { - return 0, fmt.Errorf("failed to count the number of files in %q: %v", dirPath, err) - } - out = strings.TrimSpace(out) - return strconv.Atoi(out) -} - -func DirSumFileSizes(dirPath string) (uint64, error) { - cmd := fmt.Sprintf("find %s -type f | xargs wc -c | tail -1", dirPath) - outputBytes, err := exec.Command("/bin/sh", "-c", cmd).Output() - out := string(outputBytes) - if err != nil || out == "" { - return 0, fmt.Errorf("failed to correctly sum file sizes in %q: %v", dirPath, err) - } - i := strings.IndexByte(out, ' ') - if i < 0 { - debug.Assertf(out[0] == '0', "failed to sum file sizes in %q: [%s]", dirPath, out) - return 0, nil - } - return strconv.ParseUint(out[:i], 10, 0) -}