summaryrefslogtreecommitdiff
path: root/src/devices/file/circular_path_buffer.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2024-07-30 18:30:46 +1200
committerBen Bridle <ben@derelict.engineering>2024-07-30 18:30:46 +1200
commitebfb38ebb2dff3dcb353b9d8cd01d41d9abf486e (patch)
tree03494c577c1a9c755c64ef999c074bcc8ca4dcb5 /src/devices/file/circular_path_buffer.rs
parentc23f1eda935a514b886b79f85ce0dab3080c33ef (diff)
downloadbedrock-pc-ebfb38ebb2dff3dcb353b9d8cd01d41d9abf486e.zip
Update file device to compile on Windows
Construction of OsStrings is handled differently between Windows and Unix, using platform-specific APIs. The method OsStr::as_bytes was also changed to OsStr::as_encoded_bytes at some point between Rust versions 1.69 and 1.80.
Diffstat (limited to 'src/devices/file/circular_path_buffer.rs')
-rw-r--r--src/devices/file/circular_path_buffer.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/devices/file/circular_path_buffer.rs b/src/devices/file/circular_path_buffer.rs
index f828f73..e5d903b 100644
--- a/src/devices/file/circular_path_buffer.rs
+++ b/src/devices/file/circular_path_buffer.rs
@@ -1,6 +1,4 @@
-use std::ffi::OsString;
-use std::os::unix::ffi::OsStringExt;
-use std::path::PathBuf;
+use super::*;
pub struct CircularPathBuffer {
buffer: [u8; 256],
@@ -52,10 +50,9 @@ impl CircularPathBuffer {
pub fn push_byte(&mut self, value: u8) -> Option<PathBuf> {
if value == 0x00 {
let pointer = self.pointer as usize;
- let vec = self.buffer[..pointer].to_vec();
+ let path = bytes_to_path(&self.buffer[..pointer]);
self.clear();
- let os_string: OsString = OsStringExt::from_vec(vec);
- Some(os_string.into())
+ Some(path)
} else {
let pointer = self.pointer as usize;
self.pointer = self.pointer.wrapping_add(1);