about summary refs log tree commit diff
path: root/src/libstd/sys/windows/fs.rs
AgeCommit message (Collapse)AuthorLines
2019-04-10std: Add `{read,write}_vectored` for more typesAlex Crichton-1/+9
This commit implements the `{read,write}_vectored` methods on more types in the standard library, namely: * `std::fs::File` * `std::process::ChildStd{in,out,err}` * `std::io::Std{in,out,err}` * `std::io::Std{in,out,err}Lock` * `std::io::Std{in,out,err}Raw` Where supported the OS implementations hook up to native support, otherwise it falls back to the already-defaulted implementation.
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-2/+2
2019-03-02Auto merge of #58216 - pitdicker:sqos_flags, r=alexcrichtonbors-2/+5
Set secure flags when opening a named pipe on Windows Fixes https://github.com/rust-lang/rust/issues/42036, see also the previous attempt in https://github.com/rust-lang/rust/pull/44556. Whether this is correct depends on if it is somehow possible to create a symlink to a named pipe, outside the named pipe filesystem (NPFS). But as far as I can tell that should be impossible. Also fixes that `security_qos_flags(SECURITY_ANONYMOUS)` does not set the `SECURITY_SQOS_PRESENT` flag, and the incorrect documentation about the default value of `security_qos_flags`.
2019-02-28libstd => 2018Taiki Endo-14/+14
2019-02-15Fix SECURITY_SQOS_PRESENT missingPaul Dicker-2/+5
if security_qos_flags(SECURITY_ANONYMOUS) is set
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-02-11Add an unstable FileTypeExt extension trait for WindowsPeter Atashian-0/+3
2018-02-03Somehow this function got flipped aroundPeter Atashian-3/+3
Unflip it
2018-02-03Go back to files directories and symlinks being mutually exclusivePeter Atashian-13/+17
Be smarter about what a symlink is however
2018-02-01This internal only method is no longer needed.Peter Atashian-3/+0
2018-02-01Rewrite remove_dir_all to be correctPeter Atashian-3/+5
The fact that this had to be rewritten does not bode well
2018-02-01This is what FileType on Windows should ideally be.Peter Atashian-20/+19
2017-12-23Annotate raw pointer target typesChristopher Durham-1/+1
cc https://github.com/rust-lang/rust/issues/46906 cc https://github.com/rust-lang/rust/pull/46914
2017-09-27Made `fs::copy` return the length of the main streamStephane Raux-4/+4
On Windows with the NTFS filesystem, `fs::copy` would return the sum of the lengths of all streams, which can be different from the length reported by `metadata` and thus confusing for users unaware of this NTFS peculiarity. This makes `fs::copy` return the same length `metadata` reports which is the value it used to return before PR #26751. Note that alternate streams are still copied; their length is just not included in the returned value. This change relies on the assumption that the stream with index 1 is always the main stream in the `CopyFileEx` callback. I could not find any official document confirming this but empirical testing has shown this to be true, regardless of whether the alternate stream is created before or after the main stream. Resolves #44532
2017-08-09Fix errors on WindowsAriel Ben-Yehuda-2/+2
2017-06-20Add `Read::initializer`.Steven Fackler-4/+0
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
2017-01-09Support unprivileged symlink creation in WindowsChris Morgan-3/+19
Symlink creation on Windows has in the past basically required admin; it’s being opened up a bit in the Creators Update, so that at least people who have put their computers into Developer Mode will be able to create symlinks without special privileges. (Microsoft are being cautious about it all; the Developer Mode requirement makes it so that it this won’t be as helpful as I’d like, but it’s still an improvement over requiring admin.) Because of compatibility concerns, they’ve hidden this new functionality behind a new flag in the CreateSymbolicLink dwFlags: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE. So we add this flag in order to join the party. Older Windows doesn’t like this new flag, though, so if we encounter ERROR_INVALID_PARAMETER we try again without the new flag. Sources: - https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/ is the official announcement (search for CreateSymbolicLink) - https://news.ycombinator.com/item?id=13096354 on why the new flag. - https://twitter.com/richturn_ms/status/818167548269051905 confirming that Developer Mode will still be required.
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-1/+2
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-11-22Add a method for setting permissions directly on an open file.Steven Allen-0/+18
On unix like systems, the underlying file corresponding to any given path may change at any time. This function makes it possible to set the permissions of the a file corresponding to a `File` object even if its path changes.
2016-10-16impl Debug for ReadDirDavid Henningsson-0/+8
It is good practice to implement Debug for public types, and indicating what directory you're reading seems useful. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-10-09Implement reading and writing atomically at certain offsetsTobias Bucher-0/+8
These functions allow to read from and write to a file in one atomic action from multiple threads, avoiding the race between the seek and the read. The functions are named `{read,write}_at` on non-Windows (which don't change the file cursor), and `seek_{read,write}` on Windows (which change the file cursor).
2016-09-04Replace `_, _, _` with `..`Vadim Petrochenkov-1/+1
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-1/+0
2016-08-05Comment on the casts in the `seek` implementations on filesTobias Bucher-0/+2
2016-07-12Auto merge of #34757 - sourcefrog:debug-filetype, r=alexcrichtonbors-1/+1
Derive Debug on FileType. Partially fixes #32054
2016-07-10Derive Debug on FileType.Martin Pool-1/+1
Partially fixes #32054
2016-07-06rustc: Update stage0 to beta-2016-07-06Alex Crichton-1/+1
Hot off the presses, let's update our stage0 compiler!
2016-06-09use the slice_pat hack in libstd tooAriel Ben-Yehuda-3/+3
2016-05-03Fix build on WindowsSeo Sanghyeon-1/+0
2016-03-22fix alignmentJorge Aparicio-1/+1
2016-03-22try! -> ?Jorge Aparicio-53/+53
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-0/+5
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-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/+62
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-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-5/+26
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-02Enable more fs tests on WindowsPaul Dicker-114/+58
2016-01-26Fix warnings during testsAlex Crichton-2/+2
The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well.
2016-01-20Remove raw pointer from OpenOptions structPaul Dicker-3/+3
Otherwise it is not Send and Sync anymore
2016-01-15Addressed commentsPaul Dicker-7/+9
2016-01-13Implement RFC 1252 expanding the OpenOptions structurePaul Dicker-66/+90
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.
2015-11-21Also check for NULs in environment variablesTobias Bucher-10/+3
This check is necessary, because the underlying API only reads strings until the first NUL.
2015-11-19Error when paths contain NUL charactersTobias Bucher-19/+24
On Windows: Previously these paths were silently truncated at these NUL characters, now they fail with `ErrorKind::InvalidInput`.