summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2018-09-12 07:28:48 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-09-12 10:28:48 -0400
commit26081a32dfaf34fdc8b6cf53222c15f3d4e4f30d (patch)
tree57013e4fac5d49ac526e47ab67c816626288785c /src
parent1ffae651655746b95dd40207d91ba7c360b90c40 (diff)
Add unix-only `mode` for FileInfo (#732)
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs13
-rw-r--r--src/msg.fbs2
2 files changed, 15 insertions, 0 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index 18152c682..681f18812 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -15,6 +15,8 @@ use msg;
use remove_dir_all::remove_dir_all;
use std;
use std::fs;
+#[cfg(any(unix))]
+use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use std::time::UNIX_EPOCH;
use std::time::{Duration, Instant};
@@ -504,6 +506,16 @@ macro_rules! to_seconds {
}};
}
+#[cfg(any(unix))]
+fn get_mode(perm: fs::Permissions) -> i32 {
+ (perm.mode() as i32)
+}
+
+#[cfg(not(any(unix)))]
+fn get_mode(_perm: fs::Permissions) -> i32 {
+ -1
+}
+
fn handle_stat(_d: *const DenoC, base: &msg::Base) -> Box<Op> {
let msg = base.msg_as_stat().unwrap();
let cmd_id = base.cmd_id();
@@ -529,6 +541,7 @@ fn handle_stat(_d: *const DenoC, base: &msg::Base) -> Box<Op> {
modified: to_seconds!(metadata.modified()),
accessed: to_seconds!(metadata.accessed()),
created: to_seconds!(metadata.created()),
+ mode: get_mode(metadata.permissions()),
..Default::default()
},
);
diff --git a/src/msg.fbs b/src/msg.fbs
index 4437ad1bc..458f5f437 100644
--- a/src/msg.fbs
+++ b/src/msg.fbs
@@ -211,6 +211,8 @@ table StatRes {
modified:ulong;
accessed:ulong;
created:ulong;
+ mode: int = -1;
+ // negative mode for invalid (Windows); default to invalid
}
root_type Base;