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

Add filepath fix for windows. #23

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

SilverTorus
Copy link
Contributor

The EpubDoc struct was unable read files in the epub archive on Windows due to the behavior of Pathbuf.join() method. This fix forcibly coerces the separators to Unix-style separators, so that the ZipArchive struct in the zip-rs dependency searches for the file at the proper file path. Previously on Windows, the EpubDoc resources contained paths with a mix of escaped windows separators and Unix separators (Example: OEBPS\Text/part0000.html).

This pull request creates a private helper function in the EpubDoc struct that replaces Windows separators with Unix separators. I did this instead of using each OS's respective path separator because upon testing it appeared that the ZipArchive struct from zip-rs requires paths with Unix separators or it will not be able to find the files within the archive.

I have tested this code on both Linux and Windows and it runs properly, so I assume that it would also run on MacOS as well.

It is a minor change, but feel free to edit and/or modify this request's code as you see fit. I still have much to learn about Rust, so there may well be better ways to write this function. Also, this is my first pull request, so I hope I have done everything properly.

EpubDoc could not read files in the epub archive on Windows due to the default behavior of Pathbuf.join() method. This fix forcibly coerces the separators to Unix-style separators, so that ZipArchive in the zip-rs dependency searches for the file at the proper filepath.
EpubDoc could not read files in the epub archive on Windows due to the default behavior of Pathbuf.join() method. This fix forcibly coerces the separators to Unix-style separators, so that ZipArchive in the zip-rs dependency searches for the file at the proper filepath.
@danigm danigm merged commit b81f33d into danigm:master Jan 4, 2021
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

Successfully merging this pull request may close these issues.

2 participants