Rollup merge of - joboet:move_pal_path, r=ChrisDenton

Move path implementations into `sys`

Part of .

r? `@ChrisDenton`
This commit is contained in:
Matthias Krüger 2024-02-09 19:21:16 +01:00 committed by GitHub
commit 434f080895
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 24 additions and 51 deletions

@ -7,6 +7,7 @@ mod personality;
pub mod cmath;
pub mod os_str;
pub mod path;
// FIXME(117276): remove this, move feature implementations into individual
// submodules.

@ -28,8 +28,6 @@ pub mod io;
pub mod memchr;
pub mod net;
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -22,7 +22,6 @@ pub mod io;
pub mod memchr;
pub mod net;
pub mod os;
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -29,7 +29,6 @@ pub mod fs;
pub mod io;
pub mod net;
pub mod os;
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -25,8 +25,6 @@ pub mod net;
#[path = "../unsupported/once.rs"]
pub mod once;
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -26,7 +26,6 @@ pub mod net;
#[path = "../unsupported/once.rs"]
pub mod once;
pub mod os;
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -1,25 +0,0 @@
use super::unsupported;
use crate::ffi::OsStr;
use crate::io;
use crate::path::{Path, PathBuf, Prefix};
pub const MAIN_SEP_STR: &str = "\\";
pub const MAIN_SEP: char = '\\';
#[inline]
pub fn is_sep_byte(b: u8) -> bool {
b == b'\\'
}
#[inline]
pub fn is_verbatim_sep(b: u8) -> bool {
b == b'\\'
}
pub fn parse_prefix(_p: &OsStr) -> Option<Prefix<'_>> {
None
}
pub(crate) fn absolute(_path: &Path) -> io::Result<PathBuf> {
unsupported()
}

@ -27,7 +27,6 @@ pub mod net;
#[cfg(target_os = "l4re")]
pub use self::l4re::net;
pub mod os;
pub mod path;
pub mod pipe;
pub mod process;
pub mod rand;

@ -9,8 +9,6 @@ pub mod locks;
pub mod net;
pub mod once;
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
pub mod pipe;
pub mod process;
pub mod stdio;

@ -30,8 +30,6 @@ pub mod io;
pub mod net;
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -28,8 +28,6 @@ pub mod io;
pub mod net;
#[path = "../unsupported/os.rs"]
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -16,8 +16,8 @@ use crate::sys::{c, cvt, Align8};
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::thread;
use super::path::maybe_verbatim;
use super::{api, to_u16s, IoResult};
use crate::sys::path::maybe_verbatim;
pub struct File {
handle: Handle,

@ -23,7 +23,6 @@ pub mod locks;
pub mod memchr;
pub mod net;
pub mod os;
pub mod path;
pub mod pipe;
pub mod process;
pub mod rand;
@ -210,7 +209,7 @@ pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
// Once the syscall has completed (errors bail out early) the second closure is
// yielded the data which has been read from the syscall. The return value
// from this closure is then the return value of the function.
fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
pub fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
where
F1: FnMut(*mut u16, c::DWORD) -> c::DWORD,
F2: FnOnce(&[u16]) -> T,
@ -274,7 +273,7 @@ where
}
}
fn os2path(s: &[u16]) -> PathBuf {
pub fn os2path(s: &[u16]) -> PathBuf {
PathBuf::from(OsString::from_wide(s))
}

@ -12,8 +12,6 @@ pub mod io;
pub mod locks;
pub mod net;
pub mod os;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -24,10 +24,6 @@ pub mod net;
#[path = "../unsupported/once.rs"]
pub mod once;
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]

@ -0,0 +1,18 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "windows")] {
mod windows;
pub use windows::*;
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
mod sgx;
pub use sgx::*;
} else if #[cfg(any(
target_os = "uefi",
target_os = "solid_asp3",
))] {
mod unsupported_backslash;
pub use unsupported_backslash::*;
} else {
mod unix;
pub use unix::*;
}
}

@ -1,8 +1,8 @@
use super::{c, fill_utf16_buf, to_u16s};
use crate::ffi::{OsStr, OsString};
use crate::io;
use crate::path::{Path, PathBuf, Prefix};
use crate::ptr;
use crate::sys::pal::{c, fill_utf16_buf, os2path, to_u16s};
#[cfg(test)]
mod tests;
@ -339,6 +339,6 @@ pub(crate) fn absolute(path: &Path) -> io::Result<PathBuf> {
// `lpfilename` is a pointer to a null terminated string that is not
// invalidated until after `GetFullPathNameW` returns successfully.
|buffer, size| unsafe { c::GetFullPathNameW(lpfilename, size, buffer, ptr::null_mut()) },
super::os2path,
os2path,
)
}