mirror of
https://github.com/denoland/deno.git
synced 2025-02-23 21:53:26 -05:00
Add error handling for both unix and windows
This commit is contained in:
parent
dd69f76690
commit
054c7b1c0c
2 changed files with 12 additions and 2 deletions
|
@ -895,7 +895,7 @@ fn stat_extra(
|
||||||
|
|
||||||
let result = get_dev(file_handle);
|
let result = get_dev(file_handle);
|
||||||
fsstat.dev = result?;
|
fsstat.dev = result?;
|
||||||
fsstat.ctime = Some(get_change_time(file_handle).unwrap());
|
fsstat.ctime = get_change_time(file_handle).ok();
|
||||||
|
|
||||||
CloseHandle(file_handle);
|
CloseHandle(file_handle);
|
||||||
|
|
||||||
|
|
12
ext/io/fs.rs
12
ext/io/fs.rs
|
@ -155,6 +155,16 @@ impl FsStat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn get_ctime(ctime_or_0: i64) -> Option<u64> {
|
||||||
|
if ctime_or_0 > 0 {
|
||||||
|
// ctime return seconds since epoch, but we need milliseconds
|
||||||
|
return Some(ctime_or_0 as u64 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
is_file: metadata.is_file(),
|
is_file: metadata.is_file(),
|
||||||
is_directory: metadata.is_dir(),
|
is_directory: metadata.is_dir(),
|
||||||
|
@ -164,7 +174,7 @@ impl FsStat {
|
||||||
mtime: to_msec(metadata.modified()),
|
mtime: to_msec(metadata.modified()),
|
||||||
atime: to_msec(metadata.accessed()),
|
atime: to_msec(metadata.accessed()),
|
||||||
birthtime: to_msec(metadata.created()),
|
birthtime: to_msec(metadata.created()),
|
||||||
ctime: Some(unix_or_zero!(ctime) as u64 * 1000),
|
ctime: get_ctime(unix_or_zero!(ctime)),
|
||||||
|
|
||||||
dev: unix_or_zero!(dev),
|
dev: unix_or_zero!(dev),
|
||||||
ino: unix_or_zero!(ino),
|
ino: unix_or_zero!(ino),
|
||||||
|
|
Loading…
Add table
Reference in a new issue