Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArchiveEntry.Key is dependent on the archivetype #201

Closed
evpxregu opened this issue Dec 10, 2016 · 4 comments
Closed

ArchiveEntry.Key is dependent on the archivetype #201

evpxregu opened this issue Dec 10, 2016 · 4 comments
Assignees
Labels

Comments

@evpxregu
Copy link

evpxregu commented Dec 10, 2016

Hi,

When I run the following code the directory seperator in the IArchiveEntry.Key is different for different archive types.

var _archive = new ArchiveFactory.Open(file, options);
foreach (var entry in _archive.Entries)
{
    Console.WriteLine(entry.Key);
}

Output for a .rar file:

subfolder\folder in subfolder\test fiel in sub-sub-subfolder.txt
subfolder\test fiel in sub-subfolder.txt
subfolder\folder in subfolder

output for a .zip file

subfolder/folder in subfolder/test fiel in sub-sub-subfolder.txt
subfolder/test fiel in sub-subfolder.txt
subfolder/folder in subfolder 0

Is this by design or a bug? Both archives are created on the same computer.

@adamhathcock
Copy link
Owner

It seems likely there's a bug in creating where I hardcoded the path separator. I'm not sure I should use he OS's separator or always pick one.

The archive specs may have one specifically. I'll have to look it up.

@leezer3
Copy link
Contributor

leezer3 commented Dec 11, 2016

#114

You've got a hardcoded path separator issue in your RAR extractor
https://github.com/adamhathcock/sharpcompress/blob/master/src/SharpCompress/Common/Rar/Headers/FileHeader.cs#L168

Dumping the switch statement in favour of this ought to fix it:

if (Path.DirectorySeparatorChar == '/')
{
	return path.Replace('\\', '/');
}
else if (Path.DirectorySeparatorChar == '\\')
{
	return path.Replace('/', '\\');
}

RAR always wants a \ as it's path separator.
Note:
Haven't tested this on create, hence why I'm not running up a pull request, but I don't see any reason for it to fail.

@adamhathcock
Copy link
Owner

I'll look into this soon. I was thinking archive formats want something specific and SharpCompress will have to adjust it one top of the formats like you're saying.

@adamhathcock
Copy link
Owner

Finally made a PR for this #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants