@@ -43,16 +43,22 @@ func (f File) Stat() (fs.FileInfo, error) { return f.FileInfo, nil }
43
43
44
44
// FilesFromDisk returns a list of files by walking the directories in the
45
45
// given filenames map. The keys are the names on disk, and the values are
46
- // their associated names in the archive. For convenience, empty values are
47
- // interpreted as the base name of the file (sans path) in the root of the
48
- // archive; and values that end in a slash will use the bae name of the file
49
- // in that folder of the archive. Keys that specify directories on disk will
50
- // be walked and added to the archive recursively, rooted at the named
51
- // directory.
46
+ // their associated names in the archive.
47
+ //
48
+ // Map keys that specify directories on disk will be walked and added to the
49
+ // archive recursively, rooted at the named directory. They should use the
50
+ // platform's path separator (backslash on Windows; slash on everything else).
51
+ //
52
+ // Map values should typically use slash ('/') as the separator regardless of
53
+ // the platform, as most archive formats standardize on that rune as the
54
+ // directory separator for filenames within an archive. For convenience, map
55
+ // values that are empty string are interpreted as the base name of the file
56
+ // (sans path) in the root of the archive; and map values that end in a slash
57
+ // will use the base name of the file in that folder of the archive.
52
58
//
53
59
// File gathering will adhere to the settings specified in options.
54
60
//
55
- // This function is primarily used when preparing a list of files to add to
61
+ // This function is used primarily when preparing a list of files to add to
56
62
// an archive.
57
63
func FilesFromDisk (options * FromDiskOptions , filenames map [string ]string ) ([]File , error ) {
58
64
var files []File
@@ -74,7 +80,8 @@ func FilesFromDisk(options *FromDiskOptions, filenames map[string]string) ([]Fil
74
80
return err
75
81
}
76
82
77
- nameInArchive := path .Join (rootInArchive , strings .TrimPrefix (filename , rootOnDisk ))
83
+ truncPath := strings .TrimPrefix (filename , rootOnDisk )
84
+ nameInArchive := path .Join (rootInArchive , filepath .ToSlash (truncPath ))
78
85
var linkTarget string
79
86
80
87
if isSymlink (info ) {
0 commit comments