// Create a File struct for a new, possibly (likely) non-existent file // but based on the attributes of a given, real file // This is handy for creating a target File for syncing to a destination // Note that this expects any protocol part of the path to be removed func MkToFile(fromBase string, toBase string, file fs.File) fs.File { // src: /foo/bar/baz/bat.txt // dest: /lol/ // target: /lol/bat.txt // src: /foo/bar/baz // dest: s3:///lol // target: s3:///lol/foo/bar/baz // TODO: This needs some work path := fmt.Sprintf("%s", strings.Replace(LinuxPath(file.Path()), LinuxPath(fromBase), LinuxPath(toBase), -1)) toFile := fs.File{ FileName: file.Name(), FilePath: path, FileMode: file.Mode(), FileSize: file.Size(), FileModTime: file.ModTime(), } return toFile }