about summary refs log tree commit diff
path: root/src/libstd/fs.rs
AgeCommit message (Collapse)AuthorLines
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.
2018-02-23Clarify interfaction between File::set_len and file cursorjethrogb-0/+4
2018-02-17Wording fixes from review for File.Alexis Hunt-5/+5
2018-02-16Add a warning to File about mutability.Alexis Hunt-0/+15
Fixes #47708.
2018-02-05Rollup merge of #47999 - jaystrictor:master, r=Mark-Simulacrumkennytm-1/+1
Remove 'the this' in doc comments.
2018-02-04Remove 'the this' in doc comments.Jay Strict-1/+1
2018-02-03Clarify shared file handler behavior of File::try_clone.Corey Farwell-7/+29
Fixes https://github.com/rust-lang/rust/issues/46578.
2018-01-17Rollup merge of #47520 - mbrubeck:fstat, r=Mark-SimulacrumGuillaume Gomez-7/+9
Use File::metadata instead of fs::metadata to choose buffer size This replaces a `stat` syscall with `fstat` or similar, which can be faster. Fixes #47519.
2018-01-17Use File::metadata instead of fs::metadata to choose buffer sizeMatt Brubeck-7/+9
This replaces a `stat` syscall with `fstat` or similar, which can be faster. Fixes #47519.
2018-01-14Auto merge of #47268 - EdSchouten:cloudabi-libstd, r=alexcrichtonbors-1/+1
Implement libstd for CloudABI. Though CloudABI is strongly inspired by POSIX, its absence of features that don't work well with capability-based sandboxing makes it different enough that adding bits to `sys/unix` will make things a mess. This change therefore adds CloudABI specific platform code under `sys/cloudabi`. One of the goals of this implementation is to build as much as possible directly on top of CloudABI's system call layer, as opposed to using the C library. This is preferred, as the system call layer is supposed to be stable, whereas the C library ABI technically is not. An advantage of this approach is that it allows us to implement certain interfaces, such as mutexes and condition variables more optimally. They can be lighter than the ones provided by pthreads. This change disables some modules that cannot realistically be implemented right now. For example, libstd's pathname abstraction is not designed with POSIX `*at()` (e.g., `openat()`) in mind. The `*at()` functions are the only set of file system APIs available on CloudABI. There is no global file system namespace, nor a process working directory. Discussions on how to port these modules over are outside the scope of this change.
2018-01-11Make tests build on CloudABI.Ed Schouten-1/+1
There are some tests that need to be disabled on CloudABI specifically, due to the fact that the shims cannot be built in combination with unix::ext or windows::ext. Also improve the scoping of some imports to suppress compiler warnings.
2018-01-10Pre-allocate in fs::read and fs::read_stringMatt Brubeck-2/+10
2017-12-08fs::{read, read_string, write}: add tracking issue numberSimon Sapin-3/+3
2017-12-06Rename fs::read_utf8 to read_stringSimon Sapin-4/+4
2017-11-29Generalize fs::write from &[u8] to AsRef<[u8]>Simon Sapin-3/+3
2017-11-07Add `std::fs::read_utf8`, based on `File::open` and `read_to_string`Simon Sapin-1/+53
2017-11-07Move `File::{read,write}_contents` to `fs::{read,write}` free functions.Simon Sapin-70/+71
2017-11-07Add File::read_contents and File::write_contents convenience functions.Simon Sapin-0/+79
Before: ```rust use std::fs::File; use std::io::Read; let mut bytes = Vec::new(); File::open(filename)?.read_to_end(&mut bytes)?; do_something_with(bytes) ``` After: ```rust use std::fs::File; do_something_with(File::read_contents(filename)?) ```
2017-09-27Made `fs::copy` return the length of the main streamStephane Raux-3/+18
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-09-23Rollup merge of #44759 - durka:patch-43, r=steveklabnikCorey Farwell-3/+3
improve english in create_dir_all docs Just minor nitpicking.
2017-09-21improve english in create_dir_all docsAlex Burka-3/+3
2017-09-17Add test case for unix permissionsTrevor Merrifield-0/+21
2017-09-13Add note for append method in OpenOptions docsGuillaume Gomez-0/+6