pub struct ResolveFullPath { /* private fields */ }Expand description
An owned, marshalable parameter set for GetFullPathNameW.
§Example
use windows_namespace_request_sys::full_path::ResolveFullPath;
use wtf_string::Wtf16String;
// `.` and `..` are collapsed as string work, with no component verified:
// this holds whether or not `C:\Windows\System32` exists.
let resolved = ResolveFullPath::new(Wtf16String::from(r"C:\Windows\System32\..\.\Temp"))?
.perform()?
.to_string_lossy();
assert_eq!(resolved, r"C:\Windows\Temp");§Example: it does not check existence
use windows_namespace_request_sys::full_path::ResolveFullPath;
use wtf_string::Wtf16String;
// A path to nothing resolves perfectly happily, because the call
// does not verify it. A consumer wanting a verified path wants an open
// plus GetFinalPathNameByHandleW instead.
let resolved = ResolveFullPath::new(Wtf16String::from(r"C:\no-such-directory\..\file.txt"))?
.perform()?
.to_string_lossy();
assert_eq!(resolved, r"C:\file.txt");Implementations§
Source§impl ResolveFullPath
impl ResolveFullPath
Sourcepub fn new(path: Wtf16String) -> Result<Self, PathCaptureError>
pub fn new(path: Wtf16String) -> Result<Self, PathCaptureError>
Begins a request to resolve path.
The path is kept exactly as given: this entry is the call, and fixes nothing to the current
directory at construction, which is what OpenFile and
WatchDirectory do. A caller who wants a path fixed when
the request is built uses one of those.
§Errors
PathCaptureError::InteriorNul if the path contains a NUL. Win32 reads a path up to its
first NUL, so the call would resolve a shorter path than the one named and say nothing of
it. No other variant arises here, since nothing is read at construction.
Sourcepub fn perform(&self) -> Result<Wtf16String, FullPathError>
pub fn perform(&self) -> Result<Wtf16String, FullPathError>
Performs the call on the calling thread, growing the buffer as needed.
Resolution happens against the current directory of whichever thread
performs this, which is the one thing a caller must keep in mind: a
request built on a submitter and performed on a worker resolves against
the process current directory as it stands at performance time. To
pin that at construction, build an OpenFile or
a WatchDirectory instead.
§Errors
Returns FullPathError::Win32 with the raw Win32 code, unaltered, or
FullPathError::Unstable if the required size kept changing.