about summary refs log tree commit diff
path: root/src/libstd/sys/windows
AgeCommit message (Collapse)AuthorLines
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-2/+68
This pushes the implementation detail of proxying `read_to_end` through to `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle` implementations on Unix/Windows. This way intermediate layers will also be able to take advantage of this optimized implementation. This commit also adds the optimized implementation for `ChildStdout` and `ChildStderr`.
2016-03-04Auto merge of #31945 - sfackler:net2, r=alexcrichtonbors-2/+51
I have these tagged as stable in 1.9, so this shouldn't merge until the 1.8 beta's cut.
2016-02-29std: Stabilize APIs for the 1.8 releaseAlex Crichton-2/+2
This commit is the result of the FCPs ending for the 1.8 release cycle for both the libs and the lang suteams. The full list of changes are: Stabilized * `braced_empty_structs` * `augmented_assignments` * `str::encode_utf16` - renamed from `utf16_units` * `str::EncodeUtf16` - renamed from `Utf16Units` * `Ref::map` * `RefMut::map` * `ptr::drop_in_place` * `time::Instant` * `time::SystemTime` * `{Instant,SystemTime}::now` * `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier` * `{Instant,SystemTime}::elapsed` * Various `Add`/`Sub` impls for `Time` and `SystemTime` * `SystemTimeError` * `SystemTimeError::duration` * Various impls for `SystemTimeError` * `UNIX_EPOCH` * `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign` Deprecated * Scoped TLS (the `scoped_thread_local!` macro) * `Ref::filter_map` * `RefMut::filter_map` * `RwLockReadGuard::map` * `RwLockWriteGuard::map` * `Condvar::wait_timeout_with` Closes #27714 Closes #27715 Closes #27746 Closes #27748 Closes #27908 Closes #29866
2016-02-28Fix windowsSteven Fackler-76/+43
Also back out keepalive support for TCP since the API is perhaps not actually what we want. You can't read the interval on Windows, and we should probably separate the functionality of turning keepalive on and overriding the interval.
2016-02-28Add TCP functionality from net2Steven Fackler-0/+82
2016-02-26Auto merge of #31876 - ollie27:win_fill_bytes, r=brsonbors-7/+11
CryptGenRandom takes a DWORD (u32) for the length so it only supports writing u32::MAX bytes at a time. Casting the length from a usize caused truncation meaning the whole buffer was not always filled. cc #31841 This is the same as rust-lang-nursery/rand#99. I think it's a good idea to keep the implementations in sync. r? @alexcrichton
2016-02-26Auto merge of #31858 - alexcrichton:fix-networking-cast, r=brsonbors-2/+3
Similar to #31825 where the read/write limits were capped for files, this implements similar limits when reading/writing networking types. On Unix this shouldn't affect anything because the write size is already a `usize`, but on Windows this will cap the read/write amounts to `i32::max_value`. cc #31841
2016-02-25rand: Fix filling buffers 4 GiB or larger with OsRng::fill_bytes on WindowsOliver Middleton-7/+11
CryptGenRandom takes a DWORD (u32) for the length so it only supports writing u32::MAX bytes at a time. Casting the length from a usize caused truncation meaning the whole buffer was not always filled.
2016-02-25Rollup merge of #31842 - dileepbapat:master, r=alexcrichtonManish Goregaokar-3/+2
I have made changes and built it after that. Please advise, https://github.com/rust-lang/rust/issues/31820
2016-02-24std: Cap read/write limits on Windows networkingAlex Crichton-2/+3
Similar to #31825 where the read/write limits were capped for files, this implements similar limits when reading/writing networking types. On Unix this shouldn't affect anything because the write size is already a `usize`, but on Windows this will cap the read/write amounts to `i32::max_value`. cc #31841
2016-02-24Auto merge of #31782 - pitdicker:clean_out_windows_c, r=alexcrichtonbors-210/+38
I am not entirely sure I have got everything right, but if it compiles it is ok probably... I tested it with msvc x86_64 and gnu. Somehow a lot of `EXCEPTION-*` constants are dead code when running test, no idea why. I have put `#![cfg_attr(test, allow(dead_code))]` at the top for this.
2016-02-23#31820 - Utilize `if..let` instead of single `match` branchdileepb-3/+2
2016-02-23Fix reading/writing 4 GiB or larger files on Windows 64-bitOliver Middleton-5/+11
`ReadFile` and `WriteFile` take a DWORD (u32) for the length argument which was erroneously cast from a usize causing truncation. This meant methods like `write_all` and `read_exact` would unexpectedly fail if given a buffer 4 GiB or larger. We can instead just ask for `u32::MAX` bytes if the given buffer is too big.
2016-02-21RaiseException is used by everything except x86 gnuPaul Dicker-0/+1
2016-02-21Fixes for 32-bitPaul Dicker-10/+11
2016-02-20Auto merge of #31608 - frewsxcv:osstring-simple-functions, r=alexcrichtonbors-0/+35
https://github.com/rust-lang/rust/issues/29453
2016-02-20Add Capacity/length methods for OsString.Corey Farwell-0/+35
https://github.com/rust-lang/rust/issues/29453
2016-02-20Remove dead code from sys::windows::cPaul Dicker-210/+36
2016-02-17std: restructure rand os code into sys modulesSean McArthur-0/+73
2016-02-15Refactor windows::fs::FileAttrPaul Dicker-28/+26
Because we no longer use `GetFileAttributesExW` FileAttr is never created directly from `WIN32_FILE_ATTRIBUTE_DATA` anymore. So we should no longer store FileAttr's attributes in that c struct.
2016-02-13Fixes #28528Paul Dicker-58/+72
Fix `read_link` to also be able to read the target of junctions on Windows. Also the path returned should not include a NT namespace, and there were some problems with permissions.
2016-02-13Auto merge of #31557 - retep998:house-directory, r=alexcrichtonbors-2/+2
This is the simple solution. I know @nodakai was working on a more complex solution that overhauled the `fill_utf16_buf` stuff. r? @alexcrichton
2016-02-11bootstrap: Add directives to not double-link libsAlex Crichton-0/+3
Have all Cargo-built crates pass `--cfg cargobuild` and then add appropriate `#[cfg]` definitions to all crates to avoid linking anything if this is passed. This should help allow libstd to compile with both the makefiles and with Cargo.
2016-02-11Fix usage of GetUserProfileDirectoryW in env::home_dirPeter Atashian-2/+2
Signed-off-by: Peter Atashian <retep998@gmail.com>
2016-02-10std: Push process stdio setup in std::sysAlex Crichton-93/+137
Most of this is platform-specific anyway, and we generally have to jump through fewer hoops to do the equivalent operation on Windows. One benefit for Windows today is that this new structure avoids an extra `DuplicateHandle` when creating pipes. For Unix, however, the behavior should be the same. Note that this is just a pure refactoring, no functionality was added or removed.
2016-02-10std: Lift out Windows' CreateProcess lock a bitAlex Crichton-13/+20
The function `CreateProcess` is not itself unsafe to call from many threads, the article in question is pointing out that handles can be inherited by unintended child processes. This is basically the same race as the standard Unix open-then-set-cloexec race. Since the intention of the lock is to protect children from inheriting unintended handles, the lock is now lifted out to before the creation of the child I/O handles (which will all be inheritable). This will ensure that we only have one process in Rust at least creating inheritable handles at a time, preventing unintended inheritance to children.
2016-02-10std: Rename Stdio::None to Stdio::NullAlex Crichton-6/+5
This better reflects what it's actually doing as we don't actually have an option for "leave this I/O slot as an empty hole".
2016-02-10std: Push Child's exit status to sys::processAlex Crichton-3/+5
On Unix we have to be careful to not call `waitpid` twice, but we don't have to be careful on Windows due to the way process handles work there. As a result the cached `Option<ExitStatus>` is only necessary on Unix, and it's also just an implementation detail of the Unix module. At the same time. also update some code in `kill` on Unix to avoid a wonky waitpid with WNOHANG. This was added in 0e190b9a to solve #13124, but the `signal(0)` method is not supported any more so there's no need to for this workaround. I believe that this is no longer necessary as it's not really doing anything.
2016-02-10std: Refactor process spawning on UnixAlex Crichton-3/+0
* Build up the argp/envp pointers while the `Command` is being constructed rather than only when `spawn` is called. This will allow better sharing of code between fork/exec paths. * Rename `child_after_fork` to `exec` and have it only perform the exec half of the spawning. This also means the return type has changed to `io::Error` rather than `!` to represent errors that happen.
2016-02-08Auto merge of #31468 - pitdicker:fs_tests_cleanup, r=alexcrichtonbors-1/+12
See #29412
2016-02-07Don't let `remove_dir_all` recursively remove a symlinkPaul Dicker-1/+12
See #29412
2016-02-04std: Expose SystemTime accessors on fs::MetadataAlex Crichton-8/+35
These accessors are used to get at the last modification, last access, and creation time of the underlying file. Currently not all platforms provide the creation time, so that currently returns `Option`.
2016-02-04Auto merge of #31360 - pitdicker:fs_tests_cleanup, r=alexcrichtonbors-126/+75
- use `symlink_file` and `symlink_dir` instead of the old `soft_link` - create a junction instead of a directory symlink for testing recursive_rmdir (as it causes the same troubles, but can be created by users without `SeCreateSymbolicLinkPrivilege`) - `remove_dir_all` was unable to remove directory symlinks and junctions - only run tests that create symlinks if we have the right permissions. - rename `Path2` to `Path` - remove the global `#[allow(deprecated)]` and outdated comments - After factoring out `create_junction()` from the test `directory_junctions_are_directories` and removing needlessly complex code, what I was left with was: ``` #[test] #[cfg(windows)] fn directory_junctions_are_directories() { use sys::fs::create_junction; let tmpdir = tmpdir(); let foo = tmpdir.join("foo"); let bar = tmpdir.join("bar"); fs::create_dir(&foo).unwrap(); check!(create_junction(&foo, &bar)); assert!(bar.metadata().unwrap().is_dir()); } ``` It test whether a junction is a directory instead of a reparse point. But it actually test the target of the junction (which is a directory if it exists) instead of the junction itself, which should always be a symlink. So this test is invalid, and I expect it only exists because the author was suprised by it. So I removed it. Some things that do not yet work right: - relative symlinks do not accept forward slashes - the conversion of paths for `create_junction` is hacky - `remove_dir_all` now messes with the internal data of `FileAttr` to be able to remove symlinks. We should add some method like `is_symlink_dir()` to it, so code outside the standard library can see the difference between file and directory symlinks too.
2016-02-04Allow dead code for `symlink_junction()`Paul Dicker-0/+2
2016-02-04Auto merge of #31069 - sfackler:file-try-clone, r=alexcrichtonbors-0/+6
I have it set as stable right now under the rationale that it's extending an existing, stable API to another type in the "obvious" way. r? @alexcrichton cc @reem
2016-02-04Add File::try_cloneSteven Fackler-0/+6
2016-02-03Adress commentsPaul Dicker-23/+26
2016-02-03std: Properly handle interior NULs in std::processKamal Marhubi-29/+52
This reports an error at the point of calling `Command::spawn()` or one of its equivalents. Fixes https://github.com/rust-lang/rust/issues/30858 Fixes https://github.com/rust-lang/rust/issues/30862
2016-02-02Enable more fs tests on WindowsPaul Dicker-114/+58
2016-01-26Auto merge of #31120 - alexcrichton:attribute-deny-warnings, r=brsonbors-25/+25
This commit removes the `-D warnings` flag being passed through the makefiles to all crates to instead be a crate attribute. We want these attributes always applied for all our standard builds, and this is more amenable to Cargo-based builds as well. Note that all `deny(warnings)` attributes are gated with a `cfg(stage0)` attribute currently to match the same semantics we have today
2016-01-26Fix warnings during testsAlex Crichton-25/+25
The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well.
2016-01-25std: Fix some behavior without stdio handlesAlex Crichton-3/+8
On all platforms, reading from stdin where the actual stdin isn't present should return 0 bytes as having been read rather than the entire buffer. On Windows, handle the case where we're inheriting stdio handles but one of them isn't present. Currently the behavior is to fail returning an I/O error but instead this commit corrects it to detecting this situation and propagating the non-set handle. Closes #31167
2016-01-20Auto merge of #30872 - pitdicker:expand_open_options, r=alexcrichtonbors-94/+228
Tracking issue: #30014 This implements the RFC and makes a few other changes. I have added a few extra tests, and made the Windows and Unix code as similar as possible. Part of the RFC mentions the unstable OpenOptionsExt trait on Windows (see #27720). I have added a few extra methods to future-proof it for CreateFile2.
2016-01-20Remove raw pointer from OpenOptions structPaul Dicker-3/+3
Otherwise it is not Send and Sync anymore
2016-01-15Addressed commentsPaul Dicker-34/+35
2016-01-14Fix doctestsPaul Dicker-1/+2
2016-01-13Move `custom_flags` to `OpenOptionsExt`Paul Dicker-0/+26
And mark the new methods as unstable.
2016-01-13Add missing newline character to callers of dumb_printAmanieu d'Antras-1/+1
2016-01-13Implement RFC 1252 expanding the OpenOptions structurePaul Dicker-95/+201
Tracking issue: #30014 This implements the RFC and makes a few other changes. I have added a few extra tests, and made the Windows and Unix code as similar as possible. Part of the RFC mentions the unstable OpenOptionsExt trait on Windows (see #27720). I have added a few extra methods to future-proof it for CreateFile2.
2016-01-12Add set_oom_handler and use it print a message when out of memoryAmanieu d'Antras-1/+21