Implement Preserve Flag to Extract Archive Contents to Their Containing Directory#26
Conversation
|
@davidnewhall if you're interested ^ |
|
Thanks! Will have to find some time to test it out. |
|
Now I'm curious if you can just pass the same path to |
|
Okay, it wasn't, but what I'm wondering is if this should work with |
| Output string `json:"output" toml:"output" xml:"output" yaml:"output"` | ||
| Passwords []string `json:"passwords" toml:"passwords" xml:"password" yaml:"passwords"` | ||
| Exclude []string `json:"excludeSuffix" toml:"exclude_suffix" xml:"exclude_suffix" yaml:"excludeSuffix"` | ||
| Include []string `json:"includeSuffix" toml:"include_suffix" xml:"include_suffix" yaml:"includeSuffix"` |
There was a problem hiding this comment.
so close (I did this in the GitHub UI merge commit fixer thingy. rip)
|
|
||
| // If preserving the file hierarchy, set the output directory to the | ||
| // folder of the archive being extracted. | ||
| if job.Preserve { |
There was a problem hiding this comment.
re-writing my comment from last week:
We should add some code here that does something like:
- remove input path prefix from fileName.
- append fileName Dir to job.Output.
- extract file into job.Output/fileFolder
To keep your current implementation, one would pass the same path to -o that was provided to search.
Do you want to tackle this? if not, I'll merge your contribution and do it myself.
There was a problem hiding this comment.
fwiw, this is how:
file.OutputDir = filepath.Join(job.Output, filepath.Dir(strings.TrimPrefix(folder, fileName)))
and change line 30 to
for folder, files := range archives {
I'll have a follow-up contribution tomorrow to tidy this up.
Adds a new flag
-p, --preserve-pathsthat will override the job's output directory and place any extracted files in the same directory as the archive.Closes #19