-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
windows compatibility #35
Conversation
src/main.rs
Outdated
@@ -12,6 +12,7 @@ use std::error::Error; | |||
use std::ffi::OsStr; | |||
use std::fs; | |||
use std::io::Write; | |||
#[cfg(target_os = "linux")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this still work for other Unix-like operating systems (OSX, ..)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like it; this should probably be something like target_family = "unix"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, seems like we can use
#[cfg(unix)]
and
#[cfg(not(unix))]
Thank you very much! I'm fine with the dummy-behavior for |
Maybe |
@Boscop As a point of comparison, it appears that Git-Bash treats To my mind, special-case logic trying to guess how file extensions should be treated is almost certainly the wrong approach. It is a can of worms that gets increasingly complicated; for instance, script-language files ( |
I second @BatmanAoD , executability is determined by file-wise global settings on windows but they are user-specific. Trying to infer executability based on extension is confusing, and I don't think there currently is a clear and simple method to extract this information from the registry. |
In the end, I'm okay with either of:
@sebasv What do you think about the |
change target_os->target_family
@sharkdp |
src/main.rs
Outdated
@@ -77,13 +78,17 @@ fn print_entry(base: &Path, entry: &Path, config: &FdOptions) { | |||
None => return | |||
}; | |||
|
|||
#[cfg(target_os = "unix")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be target_family
here, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, well spotted. I appreciate the keen eye!
src/main.rs
Outdated
let is_executable = |p: &std::path::PathBuf| { | ||
p.metadata() | ||
.ok() | ||
.map(|f| f.permissions().mode() & 0o111 != 0) | ||
.unwrap_or(false) | ||
}; | ||
|
||
#[cfg(not(target_os = "unix"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be target_family
here, too
oops
Thank you very much! |
Awesome! Can't wait to try this out now! |
On windows machines, the file mode is less relevant than on unix machines. On top of that the
std::os::unix::fs::PermissionsExt
crate has no windows alternative as of this moment, so the highlighting of executable files is disabled with a conditional compilation directive that verifies the target os.