summaryrefslogtreecommitdiff
path: root/src/devices/file/entry.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-01-31 07:38:50 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-01-31 07:39:07 +1300
commit28101de56231252ca0cfa6a9f107b75112c9acad (patch)
treef5c82a6894562bfb8ed8ab94e9345cefaa6fb96b /src/devices/file/entry.rs
parent30d2f099c9edf4f59fbbdd6686988ae7b0622ba2 (diff)
downloadbedrock-pc-28101de56231252ca0cfa6a9f107b75112c9acad.zip
Implement new file device interface
This is a complete redesign of the file device. The most notable addition is the ability to ascend and descend the file tree.
Diffstat (limited to 'src/devices/file/entry.rs')
-rw-r--r--src/devices/file/entry.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/devices/file/entry.rs b/src/devices/file/entry.rs
new file mode 100644
index 0000000..a91ae82
--- /dev/null
+++ b/src/devices/file/entry.rs
@@ -0,0 +1,36 @@
+use crate::*;
+
+use std::cmp::Ordering;
+
+pub enum Entry {
+ File(BufferedFile),
+ Directory(DirectoryListing),
+}
+
+#[derive(Copy, Clone, PartialEq, Eq)]
+pub enum EntryType {
+ File,
+ Directory,
+}
+
+impl PartialOrd for EntryType {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ match (self, other) {
+ (EntryType::Directory, EntryType::Directory) => Some(Ordering::Equal ),
+ (EntryType::Directory, EntryType::File ) => Some(Ordering::Less ),
+ (EntryType::File, EntryType::Directory) => Some(Ordering::Greater),
+ (EntryType::File, EntryType::File ) => Some(Ordering::Equal ),
+ }
+ }
+}
+
+impl Ord for EntryType {
+ fn cmp(&self, other: &Self) -> Ordering {
+ match (self, other) {
+ (EntryType::Directory, EntryType::Directory) => Ordering::Equal ,
+ (EntryType::Directory, EntryType::File ) => Ordering::Less ,
+ (EntryType::File, EntryType::Directory) => Ordering::Greater,
+ (EntryType::File, EntryType::File ) => Ordering::Equal ,
+ }
+ }
+}