about summary refs log tree commit diff
path: root/tvix/eval/src/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/io.rs')
-rw-r--r--tvix/eval/src/io.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tvix/eval/src/io.rs b/tvix/eval/src/io.rs
index 7e8b85c87abb..f30ef164c41a 100644
--- a/tvix/eval/src/io.rs
+++ b/tvix/eval/src/io.rs
@@ -48,6 +48,20 @@ impl std::fmt::Display for FileType {
     }
 }
 
+impl From<std::fs::FileType> for FileType {
+    fn from(value: std::fs::FileType) -> Self {
+        if value.is_file() {
+            Self::Regular
+        } else if value.is_dir() {
+            Self::Directory
+        } else if value.is_symlink() {
+            Self::Symlink
+        } else {
+            Self::Unknown
+        }
+    }
+}
+
 /// Represents all possible filesystem interactions that exist in the Nix
 /// language, and that need to be executed somehow.
 ///