summary refs log tree commit diff
path: root/library/std/src/sys/windows
AgeCommit message (Collapse)AuthorLines
2023-05-15Add creation time support to `FileTimes` on apple and windowsbeetrees-4/+18
2023-05-05Sort windows_sys.lst alphabeticallyChris Denton-614/+617
2023-05-05Use new bindingsChris Denton-52/+69
2023-05-05Generate windows-sys bindingsChris Denton-3045/+7016
2023-05-03Use `from_wide_to_user_path` in `read_link`Chris Denton-4/+7
2023-05-03Correctly convert an NT path to a Win32 pathChris Denton-11/+16
This can be done by simply changing the `\??\` prefix to `\\?\` and then attempting to convert to a user path. Currently it simply strips off the prefix which could lead to the wrong path being returned (e.g. if it's not a drive path or if the path contains trailing spaces, etc).
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+4
2023-04-28remove_dir_all: delete directory with fewer permsChris Denton-19/+22
If opening a directory with `FILE_LIST_DIRECTORY` access fails then we should try opening without requesting that access. We may still be able to delete it if it's empty or a link.
2023-04-16Windows: map a few more error codes to ErrorKindChris Denton-3/+6
NotFound errors: * `ERROR_INVALID_DRIVE`: The system cannot find the drive specified * `ERROR_BAD_NETPATH`: The network path was not found * `ERROR_BAD_NET_NAME`: The network name cannot be found. InvalidFilename: * `ERROR_BAD_PATHNAME`: The specified path is invalid.
2023-04-10Fix typos in libraryDaniPopes-1/+1
2023-04-05Fix buffer overrun in (test-only) symlink_junctionThom Chiovoloni-9/+25
2023-03-21Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplettMatthias Krüger-38/+62
Windows: make `Command` prefer non-verbatim paths When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2023-03-21Rollup merge of #108326 - tmiasko:read-buf, r=thomccnils-9/+52
Implement read_buf for a few more types Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-03-21Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrumbors-47/+40
Distribute libntdll.a with windows-gnu toolchains This allows the OS loader to load essential functions (e.g. read/write file) at load time instead of lazily doing so at runtime. r? libs
2023-03-17Modify code style as per commentsNagaChaitanya Vellanki-7/+5
2023-03-16run rustfmt on changesNagaChaitanya Vellanki-1/+1
2023-03-16fallback to lstat when stat fails on WindowsNagaChaitanya Vellanki-1/+13
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-9/+52
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-02-27Rollup merge of #107110 - strega-nil:mbtwc-wctmb, r=ChrisDentonMatthias Krüger-29/+77
[stdio][windows] Use MBTWC and WCTMB `MultiByteToWideChar` and `WideCharToMultiByte` are extremely well optimized, and therefore should probably be used when we know we can (specifically in the Windows stdio stuff). Fixes #107092
2023-02-25[stdio][windows] Use MBTWC and WCTMBNicole Mazzuca-29/+77
2023-02-23Fix `is_terminal`'s handling of long paths on Windows.Dan Gohman-19/+21
As reported in sunfishcode/is-terminal#18, there are situations where `GetFileInformationByHandleEx` can write a file name length that is longer than the provided buffer. To avoid deferencing memory past the end of the buffer, use a bounds-checked function to form a slice to the buffer and handle the out-of-bounds case. This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal` implementation.
2023-02-22Quote more batch file argumentsChris Denton-1/+10
Make sure to quote batch file arguments that contain command prompt special characters. Additionally add `/d` command line parameter to disable any commands that may change the way variable expansion works.
2023-02-20Distribute libntdll.a with windows-gnu toolchainsChris Denton-47/+40
This allows loading some essential functions (e.g. read/write file) at load time instead of lazily.
2023-02-14Revert to using `RtlGenRandom`Chris Denton-103/+31
This is required due to `BCryptGenRandom` failing to load the necessary dll on some systems.
2023-02-13Add another error to Windows file open fallbackalesito85-1/+6
Added another error to be processed in fallback Solution suggested by Chris Denton https://github.com/nushell/nushell/issues/6857#issuecomment-1426847135
2023-02-12Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcmbors-2/+1
Use associated items of `char` instead of freestanding items in `core::char` The associated functions and constants on `char` have been stable since 1.52 and the freestanding items have soft-deprecated since 1.62 (https://github.com/rust-lang/rust/pull/95566). This PR ~~marks them as "deprecated in future", similar to the integer and floating point modules (`core::{i32, f32}` etc)~~ replaces all uses of `core::char::*` with `char::*` to prepare for future deprecation of `core::char::*`.
2023-02-10Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` headerChris Denton-0/+2
Makes sure the full header is correctly initialized, including reserve parameters.
2023-01-28Replace libc::{type} with crate::ffi::{type}Ayush Singh-1/+1
Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-17refactor[std]: do not use box syntaxjoboet-1/+1
2023-01-14Remove various double spaces in source comments.André Vennberg-2/+2
2023-01-14Use associated items of `char` instead of freestanding items in `core::char`Lukas Markeffsky-2/+1
2022-12-30std: rename `Parker::new` to `Parker::new_in_place`, add safe `Parker::new` ↵joboet-1/+1
constructor for SGX
2022-12-29std: unify id-based thread parking implementationsjoboet-1/+1
2022-12-11Implement blocking outputAyush Singh-0/+5
This allows decoupling `Command::spawn` and `Command::output`. This is useful for targets which do support launching programs in blocking mode but do not support multitasking (Eg: UEFI). This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-08Add read_to_end for AnonPipeAyush Singh-1/+5
Add `read_to_end` method for `sys::{target}::pipe::AnonPipe`. This allows having a more optimized version of `read_to_end` for ChildStdout. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-07Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomccbors-14/+20
Pass on null handle values to child process Fixes #101645 In Windows, stdio handles are (semantically speaking) `Option<Handle>` where `Handle` is a non-zero value. When spawning a process with `Stdio::Inherit`, Rust currently turns zero values into `-1` values. This has the unfortunate effect of breaking console subprocesses (which typically need stdio) that are spawned from gui applications (that lack stdio by default) because the console process won't be assigned handles from the newly created console (as they usually would in that situation). Worse, `-1` is actually [a valid handle](https://doc.rust-lang.org/std/os/windows/io/struct.OwnedHandle.html) which means "the current process". So if a console process, for example, waits on stdin and it has a `-1` value then the process will end up waiting on itself. This PR fixes it by propagating the nulls instead of converting them to `-1`. While I think the current behaviour is a mistake, changing it (however justified) is an API change so I think this PR should at least have some input from t-libs-api. So choosing at random... r? `@joshtriplett`
2022-12-06Don't set `STARTF_USESTDHANDLES` if none are setChris Denton-7/+15
2022-12-02Windows: make Command prefer non-verbatim pathsChris Denton-38/+62
When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2022-12-01Auto merge of #104160 - Ayush1325:windows-args, r=m-ou-sebors-52/+2
Extract WStrUnits to sys_common::wstr This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of https://github.com/rust-lang/rust/pull/100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-28Extract WStrUnits to sys_common::wstrAyush Singh-52/+2
This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of https://github.com/rust-lang/rust/pull/100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-18Handle the case that even the filename array is unaligned.Thom Chiovoloni-5/+14
2022-11-17Don't assume `FILE_ID_BOTH_DIR_INFO` will be alignedThom Chiovoloni-5/+9
2022-11-06std: remove lock wrappers in `sys_common`joboet-26/+21
2022-11-05Rollup merge of #103995 - SUPERCILEX:typos, r=Dylan-DPCDylan DPC-5/+6
Small round of typo fixes
2022-11-04Small round of typo fixesAlex Saveau-5/+6
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-27Use stdio in UWP appsChris Denton-120/+28
This has been supported since Windows 10.0.16299. See https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-console-l1-1-0dll
2022-10-24Pass on null handle values to child processChris Denton-7/+5
2022-10-21Reduce false positives in msys2 detectionChris Denton-2/+12
This checks that: * the handle is a pipe * the pipe's file name starts with "msys-" or "cygwin-" rather than looking in the full path.
2022-10-15Auto merge of #100579 - joboet:sync_mutex_everywhere, r=thomccbors-3/+3
std: use `sync::Mutex` for internal statics Since `sync::Mutex` is now `const`-constructible, it can be used for internal statics, removing the need for `sys_common::StaticMutex`. This adds some extra allocations on platforms which need to box their mutexes (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740. I changed the program argument implementation on Hermit, it does not need `Mutex` but can use atomics like some UNIX systems (ping `@mkroening` `@stlankes).`
2022-10-15Use Align8 to avoid misalignment if the allocator or Vec doesn't align ↵Josh Triplett-7/+7
allocations