about summary refs log tree commit diff
path: root/src/libstd/fs.rs
AgeCommit message (Collapse)AuthorLines
2016-07-28Add doc examples for std::fs::MetadataGuillaume Gomez-0/+51
2016-07-26Rollup merge of #35010 - GuillaumeGomez:file_doc, r=steveklabnikSteve Klabnik-5/+23
Improve Open doc Part of #29356. r? @steveklabnik
2016-07-26Rollup merge of #35009 - GuillaumeGomez:dir_entry_doc, r=steveklabnikSteve Klabnik-12/+84
Dir entry doc Part of #29356. r? @steveklabnik
2016-07-24Improve Open docGuillaume Gomez-5/+23
2016-07-24Add DirEntry doc examplesGuillaume Gomez-0/+55
2016-07-24Add missing linksGuillaume Gomez-12/+29
2016-07-23Add DirBuilder doc examplesGuillaume Gomez-1/+18
2016-07-18Remove rustdoc reference to `walk_dir`Mark Buer-2/+2
2016-07-10Derive Debug on FileType.Martin Pool-1/+1
Partially fixes #32054
2016-06-15Fix a docs typoGleb Kozyrev-1/+1
2016-06-15Test ErrorKind::AlreadyExists for filesGleb Kozyrev-0/+9
2016-06-02Rollup merge of #34019 - kennytm:fix-33958, r=steveklabnikGuillaume Gomez-2/+3
Restore original meaning of std::fs::read_dir's example changed in #33958 `DirEntry.file_type().is_dir()` will not follow symlinks, but the original example (`fs::metadata(&path).is_dir()`) does. Therefore the change in #33958 introduced a subtle difference that now it won't enter linked folders. To preserve the same behavior, we use `Path::is_dir()` instead, which does follow symlink. (See discussion in the previous PR for detail.)
2016-06-02Restore original meaning of std::fs::read_dir's example changed in #33958.kennytm-2/+3
DirEntry.file_type().is_dir() will not follow symlinks, but the original example (fs::metadata(&path).is_dir()) does. Therefore the change in #33958 introduced a subtle difference that now it won't enter linked folders. To preserve the same behavior, we use Path::is_dir() instead, which does follow symlink.
2016-06-01allow for the future addition of a close method on FileJack O'Connor-2/+1
2016-05-31document that Files close themselves automaticallyJack O'Connor-0/+3
2016-05-30Use Path::is_dir() in fs::read_dir()'s example.kennytm-2/+2
Basically reverts #25508. The `is_dir()` function has been stable since 1.5.0.
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-3/+3
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-15Auto merge of #33251 - Kintaro:fix-typo-in-fs, r=GuillaumeGomezbors-2/+2
Fix a typo in error messages in std::fs tests Just a small correction to fix a typo in an error message in std::fs tests
2016-05-09Utilize `Result::unwrap_err` in more places.Corey Farwell-1/+1
2016-04-28Fix a typo in error messages in std::fs testsSimon Wollwage-2/+2
2016-04-12Auto merge of #31963 - barosl:rename-doc, r=alexcrichtonbors-1/+8
Describe more platform-specific behaviors of `std::fs::rename` I did some tests myself regarding the situation when both `from` and `to` exist, and the results were: On Linux: `from` | `to` | Result ---- | ---- | ---- Directory | Directory | Ok Directory | File | Error File | Directory | Error File | File | Ok On Windows: `from` | `to` | Result ---- | ---- | ---- Directory | Directory | Error Directory | File | Ok File | Directory | Error File | File | Ok This is a bit against the official MSDN documentation, which says "(`MOVEFILE_REPLACE_EXISTING`) cannot be used if `lpNewFileName` or `lpExistingFileName` names a directory." As evidenced above, `lpExistingFileName` *can* be a directory. I also mentioned the atomicity of the operation. Fixes #31301.
2016-04-12Describe more platform-specific behaviors of `std::fs::rename`Barosl Lee-1/+8
Fixes #31301.
2016-04-11std: Stabilize APIs for the 1.9 releaseAlex Crichton-5/+2
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
2016-04-06avoid "==" in assert! when one of the values is a boolTshepang Lekhonkhobe-1/+1
2016-03-22try! -> ?Jorge Aparicio-3/+3
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-20Add unix socket support to the standard librarySteven Fackler-34/+3
2016-03-12std: Clean out deprecated APIsAlex Crichton-101/+1
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-2/+4
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-04End stdlib module summaries with a full stop.Steve Klabnik-1/+1
Fixes #9447
2016-02-13Fixes #28528Paul Dicker-0/+20
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-09Minor spelling fixesCarlos E. Garcia-1/+1
2016-02-08Auto merge of #31468 - pitdicker:fs_tests_cleanup, r=alexcrichtonbors-0/+34
See #29412
2016-02-07Ignore if we can't create a symlink in this testPaul Dicker-1/+1
2016-02-07Don't let `remove_dir_all` recursively remove a symlinkPaul Dicker-0/+34
See #29412
2016-02-04std: Expose SystemTime accessors on fs::MetadataAlex Crichton-0/+67
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-57/+105
- 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-04Auto merge of #31069 - sfackler:file-try-clone, r=alexcrichtonbors-0/+34
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/+34
2016-02-03Reformat commentsPaul Dicker-12/+13
2016-02-03Adress commentsPaul Dicker-1/+33
2016-02-02Enable more fs tests on WindowsPaul Dicker-57/+72
2016-02-01docs: Standardize on 'Errors' header in std docsKamal Marhubi-1/+1
2016-01-24Auto merge of #31093 - tshepang:misc-doc-improvements, r=steveklabnikbors-5/+5
2016-01-24doc: miscellaneous OpenOptions:append improvementsTshepang Lekhonkhobe-5/+5
2016-01-23Rollup merge of #31090 - tshepang:improve-sentence, r=brsonSteve Klabnik-2/+2
2016-01-21doc: this sentence did not read wellTshepang Lekhonkhobe-2/+2
2016-01-21doc: improve grammarTshepang Lekhonkhobe-1/+1
2016-01-20Remove raw pointer from OpenOptions structPaul Dicker-0/+6
Otherwise it is not Send and Sync anymore
2016-01-15Addressed commentsPaul Dicker-16/+25
2016-01-14Fix doctestsPaul Dicker-0/+1