Skip to content

Tar truncates the first character of filename when using CreateEntryFromFile #334

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

Closed
iUnknwn opened this issue Apr 9, 2019 · 2 comments
Closed

Comments

@iUnknwn
Copy link
Contributor

iUnknwn commented Apr 9, 2019

Steps to reproduce

  1. Create an output Tar Archive
  2. Set the root path to an empty string (this happens when our code receives a relative path, so rootPath = GetDirectoryName(targetFile)).
  3. Call CreateFileFromEntry using the filename targetFile - the tarEntry has the correct name property.
  4. Call WriteEntry.
  5. Check the generated output - the filename in the generated archive is missing the leading character.

Expected behavior

The filename in the archive should be the same as what is written.

Actual behavior

The filename in the archive is missing the leading character.

Version of SharpZipLib

1.1.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet
@Numpsy
Copy link
Contributor

Numpsy commented Apr 10, 2019

I haven't tested it, but maybe the check @

should be checking if rootPath is empty rather than just null?

iUnknwn added a commit to iUnknwn/SharpZipLib that referenced this issue Apr 10, 2019
Ensures that, if the root path is an empty string, the library
will not try to take a substring of the file name (and causing the
first character to be truncated).
@iUnknwn
Copy link
Contributor Author

iUnknwn commented Apr 10, 2019

Yep - that seems like the problem. I just did a quick test, and switching that for String.IsNullOrEmpty seemed to fix the problem.

I opened a pull request with with the small change.

@piksel piksel closed this as completed in 1c3f459 Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants