about summary refs log tree commit diff
path: root/library/std/src/fs
AgeCommit message (Collapse)AuthorLines
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-1/+19
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-02-21Move `rename_directory` from ui-fulldeps to stdChris Denton-0/+16
std has had a `TempDir` implementation for a long time now.
2023-01-28Replace libc::{type} with crate::ffi::{type}Ayush Singh-2/+2
Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-3/+3
2022-12-14fs/tests: Fail fast on duplicate errors rather than looping indefinitelyTavian Barnes-2/+2
2022-12-14fs/tests: Explicitly kill the zombie rather than sleeping until it diesTavian Barnes-7/+9
2022-12-12fs: Fix #50619 (again) and add a regression testTavian Barnes-0/+26
Bug #50619 was fixed by adding an end_of_stream flag in #50630. Unfortunately, that fix only applied to the readdir_r() path. When I switched Linux to use readdir() in #92778, I inadvertently reintroduced the bug on that platform. Other platforms that had always used readdir() were presumably never fixed. This patch enables end_of_stream for all platforms, and adds a Linux-specific regression test that should hopefully prevent the bug from being reintroduced again.
2022-11-30Add test for regression for FileType equalityArthur Carcano-0/+16
Cf: https://github.com/rust-lang/rust/issues/104900
2022-07-18Ignore `hiberfil_sys` test in CIChris Denton-1/+4
The file it's testing does not exist in the CI environment.
2022-07-05Test if `[try_]exists` can find `hiberfil.sys`Chris Denton-2/+4
2022-07-05Add comment and simplify `hiberfil_sys` testChris Denton-5/+6
2022-07-05Windows: Use `FindFirstFileW` if `metadata` failsChris Denton-0/+11
Usually opening a file handle with access set to metadata only will always succeed, even if the file is locked. However some special system files, such as `C:\hiberfil.sys`, are locked by the system in a way that denies even that. So as a fallback we try reading the cached metadata from the directory.
2022-04-07Use gender neutral termsJames 'zofrex' Sanderson-3/+3
2022-03-20Add a testcase.Dan Gohman-0/+6
2022-03-11Rollup merge of #93283 - m1guelperez:master, r=Mark-SimulacrumDylan DPC-1/+9
Fix for localized windows editions in testcase fn read_link() Issue#93211 This PR aims to fix the issue with localized windows versions that do not necessarily have the folder "Documents and settings" in English. The idea was provided by `@the8472.` We check if the "CI" environment variable is set, then we always check for the "Documents and Settings"-folder, otherwise we check if the folder exists on the local machine, and if not we skip this assert. Resoles #93211.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-5/+5
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-08Fix for issue #93283Miguel Perez-1/+9
2022-01-29fs: Add a regression test for #93384Tavian Barnes-0/+16
2022-01-19Fix CVE-2022-21658 for UNIX-likeHans Kratz-0/+70
2021-12-18Update stdlib to the 2021 editionLucas Kent-5/+4
2021-12-14Fix a bunch of typosFrank Steffahn-1/+1
2021-11-19Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-seYuki Okushi-0/+4
windows: Return the "Not Found" error when a path is empty Fixes #90940
2021-11-17windows: Return the "Not Found" error when a path is emptyYuki Okushi-0/+4
2021-11-11compare between Path instead of strtamaron-12/+3
2021-10-23Make sure `CreateDirectoryW` works for path lengths > 247Chris Denton-0/+29
2021-07-29Fix may not to appropriate might not or must notAli Malik-1/+1
2021-07-10Make tests pass on old macosAris Merchant-0/+18
On old macos systems, `fs::hard_link()` will follow symlinks. This changes the test `symlink_hard_link` to exit early on these systems, so that tests can pass.
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-1/+2
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-1/+1
2021-04-18Fix test `metadata_access_times` to also check for `Unsupported`Christiaan Dirkx-1/+3
2020-11-16std: Fix test `got_symlink_permission` on WindowsVadim Petrochenkov-0/+3
2020-11-09Rollup merge of #78026 - sunfishcode:symlink-hard-link, r=dtolnayDylan DPC-0/+51
Define `fs::hard_link` to not follow symlinks. POSIX leaves it [implementation-defined] whether `link` follows symlinks. In practice, for example, on Linux it does not and on FreeBSD it does. So, switch to `linkat`, so that we can pick a behavior rather than depending on OS defaults. Pick the option to not follow symlinks. This is somewhat arbitrary, but seems the less surprising choice because hard linking is a very low-level feature which requires the source and destination to be on the same mounted filesystem, and following a symbolic link could end up in a different mounted filesystem. [implementation-defined]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html
2020-10-16Define `fs::hard_link` to not follow symlinks.Dan Gohman-0/+51
POSIX leaves it implementation-defined whether `link` follows symlinks. In practice, for example, on Linux it does not and on FreeBSD it does. So, switch to `linkat`, so that we can pick a behavior rather than depending on OS defaults. Pick the option to not follow symlinks. This is somewhat arbitrary, but seems the less surprising choice because hard linking is a very low-level feature which requires the source and destination to be on the same mounted filesystem, and following a symbolic link could end up in a different mounted filesystem.
2020-10-13Join map operatorswcampbell-2/+1
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-0/+1339
Also doing fmt inplace as requested.