Beispiel #1
0
func CopySingle(srcFs filesystem.FileSystem, srcRaw string, destFs filesystem.FileSystem, destRaw string) error {
	fromFile, _, err := utils.MakeFile(srcRaw)
	toFile := utils.MkToFile(srcRaw, destRaw, fromFile)

	if err != nil {
		logOutput("Error opening dest file: %v", err)
		return fmt.Errorf("Error opening dest file: %v", err)
	}

	if fromFile.IsDir() {
		logOutput("Mkdir %s -> %s\n", fromFile.Path(), toFile.Path())
		destFs.MkDir(toFile)
	} else {
		logOutput("Copying file: %s -> %s\n", fromFile.Path(), toFile.Path())
		bytes, err := srcFs.Read(fromFile)
		err = destFs.Write(toFile, bytes, fromFile.Mode())
		if err != nil {
			logOutput("Error copying file %s: %v", fromFile.Path(), err)
		}
	}

	return nil
}
Beispiel #2
0
func DeleteSingle(destFs filesystem.FileSystem, destRaw string) error {
	return destFs.Delete(destRaw)
}