sdf
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -5,8 +5,12 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
var verbos = flag.Bool("v",false,"show verbose")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
roots := flag.Args()
|
||||
@@ -23,13 +27,25 @@ func main() {
|
||||
close(fileSizes)
|
||||
}()
|
||||
|
||||
var nfiles,nbytes int64
|
||||
for size := range fileSizes {
|
||||
nfiles++
|
||||
nbytes += size
|
||||
}
|
||||
printDU(nfiles,nbytes)
|
||||
var tick <- chan time.Time
|
||||
|
||||
if *verbos{
|
||||
tick = time.Tick(500 * time.Millisecond)
|
||||
}
|
||||
var nfiles,nbytes int64
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
case size,ok := <- fileSizes:
|
||||
if !ok {
|
||||
break loop
|
||||
}
|
||||
nfiles++
|
||||
nbytes += size
|
||||
case <- tick:
|
||||
printDU(nfiles,nbytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printDU(nfiles, nbytes int64) {
|
||||
@@ -50,7 +66,6 @@ func WalkDir(dir string, fileSizes chan <- int64) {
|
||||
|
||||
func dirents(dir string) []os.DirEntry{
|
||||
entries, err := os.ReadDir(dir)
|
||||
fmt.Println(entries)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr,"du1: %v\n",err)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user