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:
authorAndrew Gallant <jamslam@gmail.com>2019-06-06 02:01:37 +0300
committerAndrew Gallant <jamslam@gmail.com>2020-01-28 04:27:58 +0300
commit1d7293a5a1ef548ce587a0b08abce5f21571a100 (patch)
tree891328e6665280fbfbbd15351b829c04a237b054 /src/os/windows/rawpath.rs
parente4bd92f6a791f35593185539d91f9516161ab5ac (diff)
progressag/sys
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);
+ }
+}