about summary refs log tree commit diff
path: root/src/libstd/fs.rs
AgeCommit message (Collapse)AuthorLines
2019-04-04Auto merge of #59695 - Centril:rollup-88qffc2, r=Centrilbors-2/+9
Rollup of 8 pull requests Successful merges: - #59470 (Document std::fs::File close behavior ignoring errors) - #59555 (update miri) - #59556 (update stdsimd) - #59596 (Forward formatter settings to bounds of `Range<T>` in `fmt::Debug` impl) - #59639 (Never return uninhabited values at all) - #59671 (Make some of lexer's API private) - #59685 (Add description for -Os and -Oz in rustc.1) - #59686 (Temporarily disable stack probing for gnux32.) Failed merges: r? @ghost
2019-04-04Rollup merge of #59470 - czipperz:document-fs-file-close, r=dtolnayMazdak Farrokhzad-2/+9
Document std::fs::File close behavior ignoring errors Resolves #52685
2019-04-03File: Add documentation about dropping to sync_allChris Gregory-1/+5
2019-04-03wasi: Fill out `std::fs` module for WASIAlex Crichton-0/+8
This commit fills out the `std::fs` module and implementation for WASI. Not all APIs are implemented, such as permissions-related ones and `canonicalize`, but all others APIs have been implemented and very lightly tested so far. We'll eventually want to run a more exhaustive test suite! For now the highlights of this commit are: * The `std::fs::File` type is now backed by `WasiFd`, a raw WASI file descriptor. * All APIs in `std::fs` (except permissions/canonicalize) have implementations for the WASI target. * A suite of unstable extension traits were added to `std::os::wasi::fs`. These traits expose the raw filesystem functionality of WASI, namely `*at` syscalls (opening a file relative to an already opened one, for example). Additionally metadata only available on wasi is exposed through these traits. Perhaps one of the most notable parts is the implementation of path-taking APIs. WASI actually has no fundamental API that just takes a path, but rather everything is relative to a previously opened file descriptor. To allow existing APIs to work (that only take a path) WASI has a few syscalls to learn about "pre opened" file descriptors by the runtime. We use these to build a map of existing directory names to file descriptors, and then when using a path we try to anchor it at an already-opened file. This support is very rudimentary though and is intended to be shared with C since it's likely to be so tricky. For now though the C library doesn't expose quite an API for us to use, so we implement it for now and will swap it out as soon as one is available.
2019-04-02Link to sync_allChris Gregory-1/+2
2019-04-01Document using `sync_all`Chris Gregory-4/+3
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-3/+3
2019-03-27Document std::fs::File close behavior ignoring errorsChris Gregory-1/+4
2019-03-25SGX target: fix std unit testsJethro Beekman-1/+1
2019-03-16Rollup merge of #59082 - alexreg:cosmetic-2-doc-comments, r=Centrilkennytm-1/+1
A few improvements to comments in user-facing crates Not too many this time, and all concern comments (almost all doc comments) in user-facing crates (libstd, libcore, liballoc). r? @steveklabnik
2019-03-11Improvements to comments in libstd, libcore, liballoc.Alexander Regueiro-1/+1
2019-03-04Fix typoEdward Barnard-1/+1
2019-03-04Add test for the behaviour of `fs::copy` when `to` is a symlinkEdward Barnard-0/+20
2019-03-04Change `std::fs::copy` to use `copyfile` on MacOS and iOSEdward Barnard-1/+2
2019-02-28libstd => 2018Taiki Endo-23/+24
2019-02-20Rollup merge of #58553 - scottmcm:more-ihle, r=Centrilkennytm-3/+3
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-20Rollup merge of #58530 - scottmcm:monomorphize-less, r=TimNNkennytm-9/+18
Monomorphize less code in fs::{read|write} Since the generic-ness is only for the as_refs, might as well have std just compile the important part once instead of on every use.
2019-02-17Use more impl header lifetime elisionScott McMurray-3/+3
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-16Monomorphize less code in fs::{read|write}Scott McMurray-9/+18
Since the generic-ness is only for the as_refs, might as well have std just compile the important part once instead of on every use.
2019-02-10libs: doc commentsAlexander Regueiro-13/+13
2019-02-10tests: doc commentsAlexander Regueiro-2/+2
2019-01-15Add some links in std::fs.Eric Huss-5/+17
A few items were referenced, but did not have links.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-15Fix doc of `std::fs::canonicalize`Tobias Bucher-1/+1
Point out that the final component of the path name might be a filename (and not a directory name). Previously, the doc said that all components of the path must be directory names, when it actually only ment all but the final one. Fixes #54056.
2018-12-14Fix docs path to PermissionsExtDanilo Bargen-1/+2
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-1/+1
Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from #52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-01remove some uses of try!Mark Mansi-1/+1
2018-11-20Incorporate `dyn` into more comments and docs.Corey Farwell-2/+2
2018-11-07Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwcokennytm-1/+1
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-06refactor: use shorthand fieldsteresy-1/+1
2018-11-04Add precision for create_dir functionGuillaume Gomez-0/+7
2018-10-10"(using ..." doesn't have the matching ")"Kazuyoshi Kato-1/+1
Fixes #54948.
2018-09-07Rollup merge of #53376 - frewsxcv:frewsxcv-copy, r=GuillaumeGomezkennytm-0/+6
Cross reference io::copy and fs::copy in docs. Fixes https://github.com/rust-lang/rust/issues/52524.
2018-09-04Breaking change upgradesMark Rousskov-3/+3
2018-08-14Cross reference io::copy and fs::copy in docs.Corey Farwell-0/+6
Fixes https://github.com/rust-lang/rust/issues/52524.
2018-07-08Edit code example for File::openFabian Drinck-3/+3
2018-06-01Remove feature flag from fs::read_to_string examplesteveklabnik-2/+0
This is stable, and so no longer needed
2018-05-12fs::write: Add example writing a &strAaron DeVore-0/+1
2018-05-10fs::canonicalize has some important portability concerns.Tim Allen-0/+7
2018-05-10Mention that fs::canonicalize makes paths absolute.Tim Allen-2/+2
2018-04-02Add performance note to fs::read docsMatt Brubeck-2/+6
2018-04-01Auto merge of #49522 - mbrubeck:fs_read, r=SimonSapinbors-5/+5
Rename fs::read_string to read_to_string and stabilize As approved in https://github.com/rust-lang/rust/issues/46588#issuecomment-377530365 Closes #46588.
2018-03-30Rename fs::read_string to read_to_string and stabilizeMatt Brubeck-5/+5
2018-03-30fs_read_write_bytes stabilized in 1.26.0Matt Brubeck-2/+2
2018-03-30Auto merge of #49422 - mbrubeck:fs_read, r=TimNNbors-6/+2
Stabilize fs::read and fs::write As discussed in https://github.com/rust-lang/rust/issues/46588#issuecomment-373956283
2018-03-28Auto merge of #49357 - frewsxcv:frewsxcv-termination-doc-examples, ↵bors-263/+265
r=GuillaumeGomez Remove hidden `foo` functions from doc examples; use `Termination` trait. Fixes https://github.com/rust-lang/rust/issues/49233. Easier to review with the white-space ignoring `?w=1` feature: https://github.com/rust-lang/rust/pull/49357/files?w=1
2018-03-28Stabilize fs::read and fs::writeMatt Brubeck-6/+2
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-263/+265
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-03-16Fix Issue #48345, is_file, is_dir, and is_symlink note mutual exclusionMaxwell Powlison-3/+32
The methods on the structures `fs::FileType` and `fs::Metadata` of (respectively) `is_file`, `is_dir`, and `is_symlink` had some ambiguity in documentation, where it was not noted whether files will pass those tests exclusively or not. It is now written that the tests are mutually exclusive. Fixes #48345.