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

Allow current directories in header paths #220

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ impl Header {
///
/// This function will set the pathname listed in this header, encoding it
/// in the appropriate format. May fail if the path is too long or if the
/// path specified is not Unicode and this is a Windows platform.
/// path specified is not Unicode and this is a Windows platform. Will
/// strip out any "." path component, which signifies the current directory.
pub fn set_path<P: AsRef<Path>>(&mut self, p: P) -> io::Result<()> {
self._set_path(p.as_ref())
}
Expand Down Expand Up @@ -414,7 +415,8 @@ impl Header {
///
/// This function will set the linkname listed in this header, encoding it
/// in the appropriate format. May fail if the link name is too long or if
/// the path specified is not Unicode and this is a Windows platform.
/// the path specified is not Unicode and this is a Windows platform. Will
/// strip out any "." path component, which signifies the current directory.
pub fn set_link_name<P: AsRef<Path>>(&mut self, p: P) -> io::Result<()> {
self._set_link_name(p.as_ref())
}
Expand Down
6 changes: 6 additions & 0 deletions tests/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ fn set_path() {
assert_eq!(t!(h.path()).to_str(), Some("foo\\bar"));
}

// set_path documentation explictly states it removes any ".", signfying the
// current directory, from the path. This test ensures that documented
// beavhior occurs
t!(h.set_path("./control"));
assert_eq!(t!(h.path()).to_str(), Some("control"));

let long_name = iter::repeat("foo").take(100).collect::<String>();
let medium1 = iter::repeat("foo").take(52).collect::<String>();
let medium2 = iter::repeat("fo/").take(52).collect::<String>();
Expand Down