about summary refs log tree commit diff
path: root/library/std/src/fs.rs
AgeCommit message (Collapse)AuthorLines
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-1/+9
2024-09-24Add a tracking issue for `file_buffered`Josh Stone-2/+2
2024-09-24Pre-allocate buffers in `File::open_buffered` and `create_buffered`Josh Stone-2/+8
2024-09-24Add `File::open_buffered` and `create_buffered`Josh Stone-0/+71
2024-09-21Rollup merge of #129718 - lolbinarycat:remove_dir-docs, r=NoratriebMatthias Krüger-0/+10
add guarantee about remove_dir and remove_file error kinds approved in ACP https://github.com/rust-lang/libs-team/issues/433
2024-09-20Remove double spacesnora-2/+2
2024-09-20Rollup merge of #128209 - beetrees:no-macos-10.10, r=jieyouxuGuillaume Gomez-7/+6
Remove macOS 10.10 dynamic linker bug workaround Rust's current minimum macOS version is 10.12, so the hack can be removed. This PR also updates the `remove_dir_all` docs to reflect that all supported macOS versions are protected against TOCTOU race conditions (the fallback implementation was already removed in #127683). try-job: dist-x86_64-apple try-job: dist-aarch64-apple try-job: dist-apple-various try-job: aarch64-apple try-job: x86_64-apple-1
2024-09-19[Clippy] Swap `open_options` to use diagnostic items instead of pathsGnomedDev-0/+2
2024-09-18Clarify docs for std::fs::File::writeAlexey Shekhirin-1/+1
2024-09-04Remove macOS 10.10 dynamic linker bug workaroundbeetrees-7/+6
2024-08-28add guarantee about remove_dir and remove_file error kindsbinarycat-0/+10
approved in ACP https://github.com/rust-lang/libs-team/issues/433
2024-08-22fix: fs::remove_dir_all: treat ENOENT as successbinarycat-0/+2
fixes #127576 windows implementation still needs some work
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-1/+1
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-28Update CURRENT_RUSTC_VERSIONMark Rousskov-1/+1
2024-07-26Fix doc nitsJohn Arundel-10/+10
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-24Improved clarity of documentation for std::fs::create_dir_allrik86189-7/+2
2024-06-22Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=AmanieuMatthias Krüger-8/+5
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists FCP completed in tracking issue. Tracking issue: https://github.com/rust-lang/rust/issues/83186 Closes https://github.com/rust-lang/rust/issues/83186 Stabilized API: ```rust mod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>; } ```
2024-06-16Rollup merge of #125112 - tbu-:pr_create_dir_all_empty, r=dtolnayJacob Pratt-0/+3
Document behavior of `create_dir_all` wrt. empty path The behavior makes sense because `Path::new("one_component").parent() == Some(Path::new(""))`, so if one naively wants to create the parent directory for a file to be written, it simply works. Closes #105108 by documenting the current behavior.
2024-06-14Polish `std::path::absolute` documentation.Kevin Reid-1/+1
These changes bring it closer to other standard library documentation and, in particular, `std::fs::canonicalize`, which it will often be compared with. * Add `# Platform-specific behavior` section, with content moved from Examples section. * Create `# Errors` section. * Phrase error description to allow future platforms to have new syntactic errors, rather than only emptiness. * Add missing commas. * Indent example code 4 spaces.
2024-06-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-8/+5
2024-05-21Document behavior of `create_dir_all` wrt. empty pathTobias Bucher-0/+3
The behavior makes sense because `Path::new("one_component").parent() == Some(Path::new(""))`, so if one naively wants to create the parent directory for a file to be written, it simply works. Closes #105108 by documenting the current behavior.
2024-05-20Document platform-specifics for `Read` and `Write` of `File`Tobias Bucher-0/+76
2024-05-08Rollup merge of #124782 - anatawa12:docs-create-new-already-exists, ↵Jubilee-0/+9
r=workingjubilee add note about `AlreadyExists` to `create_new` Fixes #119244
2024-05-06Apply suggestions from code reviewanatawa12-2/+6
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-05-06add note about `AlreadyExists` to `create_new`anatawa12-0/+5
2024-04-29Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple timesTobias Bucher-3/+7
Also mention that there might be leftover directories in the error case.
2024-04-17Improve std::fs::Metadata Debug representationDavid Tolnay-10/+26
Before: Metadata { file_type: FileType( FileType { mode: 0o100600 (-rw-------), }, ), is_dir: false, is_file: true, permissions: Permissions( FilePermissions { mode: 0o100600 (-rw-------), }, ), modified: Ok( SystemTime { tv_sec: 1713402981, tv_nsec: 682983531, }, ), accessed: Ok( SystemTime { tv_sec: 1713402983, tv_nsec: 206999623, }, ), created: Ok( SystemTime { tv_sec: 1713402981, tv_nsec: 682983531, }, ), .. } After: Metadata { file_type: FileType { is_dir: false, is_file: true, is_symlink: false, .. }, permissions: Permissions( FilePermissions { mode: 0o100600 (-rw-------), }, ), len: 2096, modified: SystemTime { tv_sec: 1713402981, tv_nsec: 682983531, }, accessed: SystemTime { tv_sec: 1713402983, tv_nsec: 206999623, }, created: SystemTime { tv_sec: 1713402981, tv_nsec: 682983531, }, .. }
2024-04-16Update usage note on OpenOptions::append()Hrvoje Niksic-9/+18
Avoid implying that concatenating data before passing it to `write()` (with or without `BufWriter`) ensures atomicity.
2024-04-14Rollup merge of #120900 - marcospb19:std-use-seek-stream-position, ↵Guillaume Gomez-3/+2
r=joshtriplett std: use `stream_position` where applicable by replacing `seek(SeekFrom::Current(0))` calls
2024-04-10clean up docs for `File::sync_*`Lukas Markeffsky-3/+11
2024-04-02use a consistent style for linksTshepang Mbambo-2/+2
2024-03-27Some wording improvementVagelis Prokopiou-2/+2
2024-03-26Fix link to BufWriterding-young-1/+1
2024-03-09Rollup merge of #121403 - kornelski:io-oom, r=dtolnayGuillaume Boisseau-4/+4
impl From<TryReserveError> for io::Error There's an obvious mapping between these two errors, and it makes I/O code less noisy. I've chosen to use simple `ErrorKind::OutOfMemory` `io::Error`, without keeping `TryReserveError` for the `source()`, because: * It matches current uses in libstd, * `ErrorData::Custom` allocates, which is a risky proposition for handling OOM errors specifically. * Currently `TryReserveError` has no public fields/methods, so it's usefulness is limited. How allocators should report errors, especially custom and verbose ones is still an open question. Just in case I've added note in the doccomment that this may change. The compiler forced me to declare stability of this impl. I think this implementation is simple enough that it doesn't need full-blown stabilization period, and I've marked it for the next release, but of course I can adjust the attribute if needed.
2024-03-08Rollup merge of #118623 - haydonryan:master, r=workingjubileeMatthias Krüger-4/+4
Improve std::fs::read_to_string example Resolves [#118621](https://github.com/rust-lang/rust/issues/118621) For the original code to succeed it requires address.txt to contain a socketaddress, however it is much easier to follow if this is just any strong - eg address could be a street address or just text. Also changed the variable name from "foo" to something more meaningful as cargo clippy warns you against using foo as a placeholder. ``` $ cat main.rs use std::fs; use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { let addr: String = fs::read_to_string("address.txt")?.parse()?; println!("{}", addr); Ok(()) } $ cat address.txt 123 rusty lane san francisco 94999 $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running `/home/haydon/workspace/rust-test-pr/tester/target/debug/tester` 123 rusty lane san francisco 94999 ```
2024-03-02Rollup merge of #109263 - squell:master, r=cuviperMatthias Krüger-5/+4
fix typo in documentation for std::fs::Permissions Please check and re-check this PR carefully to see if I got this right. But by my logic, if the `read_only` function returns `true`, I would not expect be able to write to the file (it being read only); so this text is meant to clarify that `read_only` being `false` doesn't mean *you* can actually write to the file, just that "in general" someone is able to.
2024-02-22remove potentially misleading sentence about libc::accessMarc Schoolderman-2/+1
2024-02-21Remove unnecessary map_errKornel-4/+4
2024-02-18Add uncontroversial syscall doc aliases to std docsSabrinaJewson-2/+16
2024-02-16Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-sebors-2/+2
Make File::read_to_end less special Follow-up to #117925
2024-02-15Update library/std/src/fs.rsHaydon Ryan-2/+2
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2024-02-15Update library/std/src/fs.rsHaydon Ryan-2/+2
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2024-02-11std: use `stream_position` where applicableJoão Marcos P. Bezerra-3/+2
by replacing `seek(SeekFrom::Current(0))` calls
2024-02-08Bump version placeholdersMark Rousskov-1/+1
2024-01-31Make File::read_to_end less specialKornel-2/+2
Follow-up to #117925
2024-01-29Handle out of memory errors in fs::read/read_to_stringKornel-4/+6
2024-01-03Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472León Orell Valerian Liehr-3/+9
Document that File does not buffer reads/writes ...and refer to `BufReader`/`BufWriter`. This is a common source of efficiency issues in Rust programs written naively. Including this information with the `File` docs, and adding a link to the wrapper types, will help discoverability.
2023-12-31Document that File does not buffer reads/writes, refer to BufReader/BufWriterCarter Hunt Fogelman-3/+9
2023-12-20stabilize `file_create_new`Ralph Ursprung-3/+1
closes #105135
2023-12-11Updating fs::read example to remove SocketAddressHaydon Ryan-2/+2