about summary refs log tree commit diff
path: root/library/std/src/os/windows
AgeCommit message (Collapse)AuthorLines
2022-02-10Implement `AsFd` for `&T` and `&mut T`.Dan Gohman-0/+32
Add implementations of `AsFd` for `&T` and `&mut T`, so that users can write code like this: ```rust pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> { ``` with `fd: F` rather than `fd: &F`. And similar for `AsHandle` and `AsSocket` on Windows. Also, adjust the `fchown` example to pass the file by reference. The code can work either way now, but passing by reference is more likely to be what users will want to do. This is an alternative to #93869, and is a simpler way to achieve the same goals: users don't need to pass borrowed-`BorrowedFd` arguments, and it prevents a pitfall in the case where users write `fd: F` instead of `fd: &F`.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-1/+1
2022-01-25Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplettMatthias Krüger-0/+107
Add a `try_clone()` function to `OwnedFd`. As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by refactoring the code out of the existing `File`/`Socket` code. r? ``@joshtriplett``
2022-01-12Use the correct `cvt` for converting socket errors on Windows.Dan Gohman-1/+2
`WSADuplicateSocketW` returns 0 on success, which differs from handle-oriented functions which return 0 on error. Use `sys::net::cvt` to handle its return value, which handles the socket convention of returning 0 on success, rather than `sys::cvt`, which handles the handle-oriented convention of returning 0 on failure.
2021-11-20Add a caveat to std::os::windows::fs::symlink_fileMichael Diamond-0/+20
This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
2021-11-11Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, ↵bors-50/+85
r=joshtriplett Fix assertion failures in `OwnedHandle` with `windows_subsystem`. As discussed in #88576, raw handle values in Windows can be null, such as in `windows_subsystem` mode, or when consoles are detached from a process. So, don't use `NonNull` to hold them, don't assert that they're not null, and remove `OwnedHandle`'s `repr(transparent)`. Introduce a new `HandleOrNull` type, similar to `HandleOrInvalid`, to cover the FFI use case. r? `@joshtriplett`
2021-10-05Document the valid values for `HandleOrNull` and `HandleOrInvalid`.Dan Gohman-0/+8
2021-10-05Suppress some cfg from being shown in the stdlib docsWim Looman-0/+2
2021-09-17modify std::os docs to be more consistentSachin Cherian-4/+27
> add intra doc links > add a usage example for the os::windows module
2021-09-09Fix Windows compilation errors.Dan Gohman-11/+6
2021-09-09Fix another Windows compilation error.Dan Gohman-1/+1
2021-09-09Fix more Windows compilation errors.Dan Gohman-5/+16
2021-09-09Fix assertion failures in `OwnedHandle` with `windows_subsystem`.Dan Gohman-40/+72
As discussed in #88576, raw handle values in Windows can be null, such as in `windows_subsystem` mode, or when consoles are detached from a process. So, don't use `NonNull` to hold them, don't assert that they're not null, and remove `OwnedHandle`'s `repr(transparent)`. Introduce a new `HandleOrNull` type, similar to `HandleOrInvalid`, to cover the FFI use case.
2021-09-09Fix Windows compilation errors.Dan Gohman-3/+11
2021-09-09Add a `try_clone()` function to `OwnedFd`.Dan Gohman-0/+87
As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by refactoring the code out of the existing `File`/`Socket` code.
2021-09-04Document when to use Windows' `symlink_dir` vs. `symlink_file`Chris Denton-2/+20
It was previously unclear which should be used when.
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-19Fix doc test failures on Windows.Dan Gohman-1/+2
2021-08-19Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI.Dan Gohman-5/+7
2021-08-19Add I/O safety trait impls for process::Stdio and process::Child.Dan Gohman-1/+25
2021-08-19Rename OptionFileHandle to HandleOrInvalid and make it just wrap an ↵Dan Gohman-80/+38
Option<OwnedHandle> The name (and updated documentation) make the FFI-only usage clearer, and wrapping Option<OwnedHandle> avoids the need to write a separate Drop or Debug impl. Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19Don't encourage migration until io_safety is stablized.Dan Gohman-4/+4
2021-08-19Add more comments about the `INVALID_HANDLE_VALUE` situation.Dan Gohman-12/+30
2021-08-19Add Safety comments to the `As*` for `Owned*` implementations.Dan Gohman-0/+6
2021-08-19Add Owned*, Borrowed*, and As* to the preludes.Dan Gohman-2/+5
2021-08-19Rename `OwnedFd`'s private field to match it's debug output.Dan Gohman-51/+52
2021-08-19Delete a spurious empty comment line.Dan Gohman-1/+0
2021-08-19Add a comment about how `OwnedHandle` should not be used with registry handles.Dan Gohman-2/+15
2021-08-19Add a comment about `OptionFileHandle`.Dan Gohman-0/+4
2021-08-19Update library/std/src/os/windows/io/socket.rsDan Gohman-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19Update library/std/src/os/windows/io/handle.rsDan Gohman-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19I/O safety.Dan Gohman-23/+684
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-07-09Use AsRef in CommandExt for raw_argKornel-3/+3
2021-07-09Unescaped command-line arguments for WindowsKornel-0/+13
Fixes #29494
2021-05-03Move `std::sys::windows::ext` to `std::os::windows`Christiaan Dirkx-0/+1143