I would like to use this crate on a project that runs on Windows:
there's no good reason to prevent Rust code running on Windows from
parsing and even creating valid RPM files after all.
Before this commit, this crate failed to build on Windows because
.mode() only exists on std::os::unix::fs::PermissionsExt. Even
with the function call protected by a cfg!(unix), the code calling
into .mode() is still compiled. The only way to work around this
general problem is to have multiple versions of the implementation
and conditionally compile a working one. You can do this via
multiple functions or macros. I decided to go with the former as it
is simpler.
The Windows implementation always returns 0. I'm not too keen about
this and it is possible to use
std::os::windows::fs::MetadataExt.file_attributes() to get at similar
data. However, this would complicate the Rust code and I highly doubt
many people will miss the functionality. For those that do, they can
pass in a pre-populated RPMFileOptionsBuilder to override the default
behavior.
It's worth noting that cargo test passes on Windows after this change.
I would like to use this crate on a project that runs on Windows: there's no good reason to prevent Rust code running on Windows from parsing and even creating valid RPM files after all.
Before this commit, this crate failed to build on Windows because
.mode()
only exists onstd::os::unix::fs::PermissionsExt
. Even with the function call protected by acfg!(unix)
, the code calling into.mode()
is still compiled. The only way to work around this general problem is to have multiple versions of the implementation and conditionally compile a working one. You can do this via multiple functions or macros. I decided to go with the former as it is simpler.The Windows implementation always returns 0. I'm not too keen about this and it is possible to use
std::os::windows::fs::MetadataExt.file_attributes()
to get at similar data. However, this would complicate the Rust code and I highly doubt many people will miss the functionality. For those that do, they can pass in a pre-populatedRPMFileOptionsBuilder
to override the default behavior.It's worth noting that
cargo test
passes on Windows after this change.