-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
use std::fs; | ||
|
||
#[cfg(any(unix, target_os = "redox"))] | ||
pub fn is_executable(md: &fs::Metadata) -> bool { | ||
use std::os::unix::fs::PermissionsExt; | ||
md.permissions().mode() & 0o111 != 0 | ||
use std::os::unix::fs::MetadataExt; | ||
|
||
/// Get the UNIX-style mode bits from some metadata if available, otherwise 0. | ||
#[allow(unused_variables)] | ||
pub fn mode(md: &fs::Metadata) -> u32 { | ||
#[cfg(any(unix, target_os = "redox"))] | ||
return md.mode(); | ||
|
||
#[cfg(not(any(unix, target_os = "redox")))] | ||
return 0; | ||
} | ||
|
||
#[cfg(any(windows, target_os = "wasi"))] | ||
pub fn is_executable(_: &fs::Metadata) -> bool { | ||
false | ||
/// Get the number of hard links to a file, or 1 if unknown. | ||
#[allow(unused_variables)] | ||
pub fn nlink(md: &fs::Metadata) -> u64 { | ||
#[cfg(any(unix, target_os = "redox"))] | ||
return md.nlink(); | ||
|
||
#[cfg(not(any(unix, target_os = "redox")))] | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters