mholt/archiver

func FilesFromDisk filenames arg, if path seperator is not system defined, pathInArchieve may be wrong path

mind-owner opened this issue · 7 comments

What version of the package or command are you using?

What are you trying to do?

What steps did you take?

What did you expect to happen, and what actually happened instead?

How do you think this should be fixed?

Please link to any related issues, pull requests, and/or discussion

Bonus: What do you use archiver for, and do you find it useful?

	map[string]string{
		"disk/folder2":             "CF", // contents added recursively
	})

I want disk/folder2/a.txt to be CF/a.txt,but it's CF/disk/folder2/a.txt, in windows

mholt commented

Thanks, I'll look into this (but I don't use Windows so I'll ask for your help to verify)

mholt commented

Ok so I just looked at the tests and this is expected. What happens if you specify disk/folder2/ or CF/ instead? (It's been a long time since I've looked at this code, but I'm pretty sure what you're asking for can be done. I just don't remember how, and probably need to improve the docs.)

mholt commented

@mind-owner You mean disk/folder2 -> disk\folder2?

If that works for you on Windows then I suggest using that 🤷‍♂️ -- nothing needs to be fixed. (We're already using filepath.* function which do account for path separators.)

mholt commented

@mind-owner If you call filepath.FromSlash() when making your map keys, does that solve it for you in a more cross-platform way? I feel like that would be the most correct solution. (I could be wrong, but not sure yet.)