Exemple #1
0
func main() {
	flag.Parse()
	files := flag.Args()
	if len(files) == 0 {
		files = util.PipedStdin()
	}

	m, err := mount.Load("./.mount")
	if err != nil {
		fmt.Println("Failed to load mount file: ", err)
		return
	}

	for _, path := range files {
		if mm, err := m.GetMeta(path); err == nil {
			if *hide {
				mm.Hidden = true
			}
			if *pth != "NOPATH" {
				mm.Path = *pth
			}
			err = m.SetMeta(path, mm)
			if err != nil {
				fmt.Println("Could not update file '" + path + "'")
			}
		}
	}
}
Exemple #2
0
func main() {
	m, err := mount.Load("./.mount")
	if err != nil {
		fmt.Println(err)
		return
	}

	fn := func(path string, info os.FileInfo, inerr error) error {
		if info.IsDir() || strings.HasSuffix(path, ".mount") {
			return nil
		}

		err := m.Snap(path)
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println("snapped '" + path + "'")
		return nil
	}

	filepath.Walk("./", fn)
	fmt.Println("Snapshot completed.")
}