mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 05:27:45 +00:00
touch: migrate winapi
to windows-sys
crate
This commit is contained in:
parent
580bff02f8
commit
f95a14537b
3 changed files with 10 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3010,7 +3010,7 @@ dependencies = [
|
||||||
"filetime",
|
"filetime",
|
||||||
"time",
|
"time",
|
||||||
"uucore",
|
"uucore",
|
||||||
"winapi",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -21,7 +21,7 @@ time = { version = "0.3", features = ["parsing", "formatting", "local-offset", "
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3" }
|
windows-sys = { version = "0.42.0", default-features = false, features = ["Win32_Storage_FileSystem", "Win32_Foundation"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "touch"
|
name = "touch"
|
||||||
|
|
|
@ -472,19 +472,16 @@ fn pathbuf_from_stdout() -> UResult<PathBuf> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
use std::os::windows::prelude::AsRawHandle;
|
use std::os::windows::prelude::AsRawHandle;
|
||||||
use winapi::shared::minwindef::{DWORD, MAX_PATH};
|
use windows_sys::Win32::Foundation::{
|
||||||
use winapi::shared::winerror::{
|
GetLastError, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY, ERROR_PATH_NOT_FOUND,
|
||||||
ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY, ERROR_PATH_NOT_FOUND,
|
HANDLE, MAX_PATH,
|
||||||
|
};
|
||||||
|
use windows_sys::Win32::Storage::FileSystem::{
|
||||||
|
GetFinalPathNameByHandleW, FILE_NAME_OPENED,
|
||||||
};
|
};
|
||||||
use winapi::um::errhandlingapi::GetLastError;
|
|
||||||
use winapi::um::fileapi::GetFinalPathNameByHandleW;
|
|
||||||
use winapi::um::winnt::WCHAR;
|
|
||||||
|
|
||||||
let handle = std::io::stdout().lock().as_raw_handle();
|
let handle = std::io::stdout().lock().as_raw_handle() as HANDLE;
|
||||||
let mut file_path_buffer: [WCHAR; MAX_PATH as usize] = [0; MAX_PATH as usize];
|
let mut file_path_buffer: [u16; MAX_PATH as usize] = [0; MAX_PATH as usize];
|
||||||
|
|
||||||
// Couldn't find this in winapi
|
|
||||||
const FILE_NAME_OPENED: DWORD = 0x8;
|
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea#examples
|
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea#examples
|
||||||
// SAFETY: We transmute the handle to be able to cast *mut c_void into a
|
// SAFETY: We transmute the handle to be able to cast *mut c_void into a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue