123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package main
- import (
- "fmt"
- "os"
- "git.wecise.com/wecise/util/filewalker"
- )
- // 同步指定文件夹中的内容
- func PrintUsage() {
- println(`Usage:
- sync <frompath> <topath>
- `)
- }
- func main() {
- var frompath, topath string
- if len(os.Args) > 2 {
- frompath = os.Args[1]
- topath = os.Args[2]
- }
- switch {
- case frompath != "" && topath != "":
- sync(frompath, topath)
- default:
- PrintUsage()
- os.Exit(1)
- }
- }
- func sync(frompath, topath string) {
- fw, err := filewalker.NewFileWalker([]string{frompath}, "") // orderby: dirfirst, filefirst, fullpath
- if err != nil {
- println(err.Error())
- }
- err = fw.List(func(basedir, fpath string) bool {
- fmt.Println(basedir, fpath)
- return true
- })
- if err != nil {
- println(err.Error())
- }
- }
|