Skip to content

Commit

Permalink
std: move path into sys
Browse files Browse the repository at this point in the history
  • Loading branch information
joboet committed Feb 8, 2024
1 parent d6c46a2 commit cbd613e
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 51 deletions.
1 change: 1 addition & 0 deletions library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/pal/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/pal/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/teeos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/pal/uefi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
25 changes: 0 additions & 25 deletions library/std/src/sys/pal/uefi/path.rs

This file was deleted.

1 change: 0 additions & 1 deletion library/std/src/sys/pal/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/unsupported/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions library/std/src/sys/pal/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -274,7 +273,7 @@ where
}
}

fn os2path(s: &[u16]) -> PathBuf {
pub fn os2path(s: &[u16]) -> PathBuf {
PathBuf::from(OsString::from_wide(s))
}

Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/xous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 0 additions & 4 deletions library/std/src/sys/pal/zkvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
18 changes: 18 additions & 0 deletions library/std/src/sys/path/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
)
}

0 comments on commit cbd613e

Please sign in to comment.