File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1125,12 +1125,17 @@ impl FusedIterator for Ancestors<'_> {}
1125
1125
pub trait PathLike {
1126
1126
/// Convert to a `Path` reference.
1127
1127
fn with_path < T , F : FnOnce ( & Path ) -> T > ( & self , f : F ) -> T ;
1128
+ /// Convert to the native platform representation of a path.
1129
+ fn with_native_path < T , F : FnOnce ( & crate :: sys:: path:: NativePath ) -> io:: Result < T > > ( & self , f : F ) -> io:: Result < T > ;
1128
1130
}
1129
1131
#[ unstable( feature = "path_like" , issue = "none" ) ]
1130
1132
impl < P : AsRef < Path > > PathLike for P {
1131
1133
fn with_path < T , F : FnOnce ( & Path ) -> T > ( & self , f : F ) -> T {
1132
1134
f ( self . as_ref ( ) )
1133
1135
}
1136
+ fn with_native_path < T , F : FnOnce ( & crate :: sys:: path:: NativePath ) -> io:: Result < T > > ( & self , f : F ) -> io:: Result < T > {
1137
+ crate :: sys:: path:: with_native_path ( self . as_ref ( ) , f)
1138
+ }
1134
1139
}
1135
1140
1136
1141
/// An owned, mutable path (akin to [`String`]).
Original file line number Diff line number Diff line change 1
1
use crate :: env;
2
- use crate :: ffi:: OsStr ;
2
+ use crate :: ffi:: { CStr , OsStr } ;
3
3
use crate :: io;
4
4
use crate :: path:: { Path , PathBuf , Prefix } ;
5
+ use crate :: sys:: common:: small_c_string:: run_path_with_cstr;
6
+
7
+ pub type NativePath = CStr ;
8
+ pub fn with_native_path < T , F : FnOnce ( & NativePath ) -> io:: Result < T > > ( path : & Path , f : F ) -> io:: Result < T > {
9
+ run_path_with_cstr ( path, f)
10
+ }
5
11
6
12
#[ inline]
7
13
pub fn is_sep_byte ( b : u8 ) -> bool {
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ mod tests;
11
11
pub const MAIN_SEP_STR : & str = "\\ " ;
12
12
pub const MAIN_SEP : char = '\\' ;
13
13
14
+ // Currently a no-op. Should convert to a wide string.
15
+ pub type NativePath = Path ;
16
+ pub fn with_native_path < T , F : FnOnce ( & NativePath ) -> T > ( path : & Path , f : F ) -> T {
17
+ f ( path)
18
+ }
19
+
14
20
/// # Safety
15
21
///
16
22
/// `bytes` must be a valid wtf8 encoded slice
You can’t perform that action at this time.
0 commit comments