mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
touch: migrate winapi to windows-sys crate
This commit is contained in:
committed by
Niyaz Nigmatullin
parent
580bff02f8
commit
f95a14537b
Generated
+1
-1
@@ -3010,7 +3010,7 @@ dependencies = [
|
||||
"filetime",
|
||||
"time",
|
||||
"uucore",
|
||||
"winapi",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[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"] }
|
||||
|
||||
[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]]
|
||||
name = "touch"
|
||||
|
||||
@@ -472,19 +472,16 @@ fn pathbuf_from_stdout() -> UResult<PathBuf> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::prelude::AsRawHandle;
|
||||
use winapi::shared::minwindef::{DWORD, MAX_PATH};
|
||||
use winapi::shared::winerror::{
|
||||
ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY, ERROR_PATH_NOT_FOUND,
|
||||
use windows_sys::Win32::Foundation::{
|
||||
GetLastError, 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 mut file_path_buffer: [WCHAR; MAX_PATH as usize] = [0; MAX_PATH as usize];
|
||||
|
||||
// Couldn't find this in winapi
|
||||
const FILE_NAME_OPENED: DWORD = 0x8;
|
||||
let handle = std::io::stdout().lock().as_raw_handle() as HANDLE;
|
||||
let mut file_path_buffer: [u16; MAX_PATH as usize] = [0; MAX_PATH as usize];
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user