Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/walkdir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/windows/rawpath.rs')
-rw-r--r--src/os/windows/rawpath.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/os/windows/rawpath.rs b/src/os/windows/rawpath.rs
new file mode 100644
index 0000000..ff6d19a
--- /dev/null
+++ b/src/os/windows/rawpath.rs
@@ -0,0 +1,29 @@
+use std::fmt;
+
+#[derive(Clone)]
+pub struct RawPathBuf {
+ /// Buf always has length at least 1 and always ends with a zero u16.
+ /// Buf only ever contains exactly 1 zero u16. (i.e., no interior NULs.)
+ buf: Vec<u16>,
+}
+
+impl fmt::Debug for RawPathBuf {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ use crate::os::windows::escaped_u16s;
+
+ f.debug_struct("RawPathBuf")
+ .field("buf", &escaped_u16s(self.as_code_units()))
+ .finish()
+ }
+}
+
+impl RawPathBuf {
+ /// Returns the code units (u16s) of this path without the NUL terminator.
+ pub fn as_code_units(&self) -> &[u16] {
+ &self.buf[..self.buf.len() - 1]
+ }
+
+ unsafe fn drop_nul(&mut self) {
+ self.buf.set_len(self.buf.len() - 1);
+ }
+}