From 65b53003e8de9543ba25a3b3d3cace399b92dc1d Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 6 Aug 2024 19:11:46 +1200 Subject: Refactor the file device The major feature of this refactor is the creation of BedrockFilePath, a type which can be losslessly converted into an operating-system specific path or a Bedrock-style byte path. It also prevents file paths which can't be represented as Bedrock-style byte paths from being constructed, and allows the use of a base directory which acts as an inescapable sandbox. BedrockFilePath will support the creation of a virtual root directory on Windows which will allow navigation between drive letters via the standard hierarchical navigation ports. This commit has been tested on Linux, but not yet Windows. Further work is expected before the new code will work on Windows. --- src/devices.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/devices.rs') diff --git a/src/devices.rs b/src/devices.rs index 9df5eb2..1d69cc7 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -204,7 +204,7 @@ impl DeviceBus for StandardDevices { // 0x8F => todo!(), // File 0x90 => read_b!(self.file.entry.is_some()), - 0x91 => read_b!(self.file.op_success), + 0x91 => read_b!(self.file.success), 0x92 => self.file.name_buffer.read_byte(), 0x93 => read_b!(self.file.entry_type()), 0x94 => self.file.read_byte(), @@ -348,14 +348,14 @@ impl DeviceBus for StandardDevices { 0x95 => self.file.write_byte(val), 0x96 => self.file.set_child_name_pointer(val), 0x97 => self.file.descend_to_child(), - 0x98 => write_hh!(self.file.new_pointer), - 0x99 => write_hl!(self.file.new_pointer), - 0x9A => write_lh!(self.file.new_pointer), - 0x9B => { write_ll!(self.file.new_pointer); self.file.commit_pointer() }, - 0x9C => write_hh!(self.file.new_length), - 0x9D => write_hl!(self.file.new_length), - 0x9E => write_lh!(self.file.new_length), - 0x9F => { write_ll!(self.file.new_length); self.file.commit_length() }, + 0x98 => write_hh!(self.file.pointer), + 0x99 => write_hl!(self.file.pointer), + 0x9A => write_lh!(self.file.pointer), + 0x9B => { write_ll!(self.file.pointer); self.file.commit_pointer() }, + 0x9C => write_hh!(self.file.length), + 0x9D => write_hl!(self.file.length), + 0x9E => write_lh!(self.file.length), + 0x9F => { write_ll!(self.file.length); self.file.commit_length() }, _ => unimplemented!("Writing to device port 0x{port:02x}"), }; -- cgit v1.2.3-70-g09d2