0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

Here is the English translation:

If there are directories in a zip file compressed on the Windows platform, the "\\" in the filepath will cause the files to be extracted normally on Linux, and ls will show filenames containing single quotes.

So when compressing, I replace "\\" with "/" so that it seems there are no issues on both Windows and Linux.
This commit is contained in:
zx9597446 2023-08-17 12:07:07 +08:00
parent ef68dfa54c
commit d724f11297

View file

@ -402,6 +402,7 @@ func ZipDirectory(destination string, source string) (err error) {
} }
defer f1.Close() defer f1.Close()
zipPath := strings.ReplaceAll(path, source, strings.TrimSuffix(destination, ".zip")) zipPath := strings.ReplaceAll(path, source, strings.TrimSuffix(destination, ".zip"))
zipPath = filepath.ToSlash(zipPath)
w1, err := writer.Create(zipPath) w1, err := writer.Create(zipPath)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)