mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-13 21:52:37 +00:00
implement for windows too
This commit is contained in:
parent
bb23164d3b
commit
95c8234e12
1 changed files with 7 additions and 15 deletions
|
@ -7,19 +7,9 @@ use std::fs::Metadata;
|
||||||
pub enum FileType {
|
pub enum FileType {
|
||||||
BlockDevice,
|
BlockDevice,
|
||||||
CharDevice,
|
CharDevice,
|
||||||
Directory {
|
Directory { uid: bool },
|
||||||
uid: bool,
|
File { uid: bool, exec: bool },
|
||||||
},
|
SymLink { is_dir: bool },
|
||||||
File {
|
|
||||||
uid: bool,
|
|
||||||
exec: bool,
|
|
||||||
},
|
|
||||||
#[cfg(unix)]
|
|
||||||
SymLink {
|
|
||||||
is_dir: bool,
|
|
||||||
},
|
|
||||||
#[cfg(windows)]
|
|
||||||
SymLink,
|
|
||||||
Pipe,
|
Pipe,
|
||||||
Socket,
|
Socket,
|
||||||
Special,
|
Special,
|
||||||
|
@ -59,7 +49,7 @@ impl FileType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn new(meta: &Metadata, permissions: &Permissions) -> Self {
|
pub fn new(meta: &Metadata, symlink_is_dir: Option<bool>, permissions: &Permissions) -> Self {
|
||||||
let file_type = meta.file_type();
|
let file_type = meta.file_type();
|
||||||
|
|
||||||
if file_type.is_file() {
|
if file_type.is_file() {
|
||||||
|
@ -72,7 +62,9 @@ impl FileType {
|
||||||
uid: permissions.setuid,
|
uid: permissions.setuid,
|
||||||
}
|
}
|
||||||
} else if file_type.is_symlink() {
|
} else if file_type.is_symlink() {
|
||||||
FileType::SymLink
|
FileType::SymLink {
|
||||||
|
is_dir: symlink_is_dir.expect("symlink must provide is_dir"),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FileType::Special
|
FileType::Special
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue