about summary refs log tree commit diff
path: root/library/std/src/os/unix/fs.rs
AgeCommit message (Collapse)AuthorLines
2025-09-03Add `read_buf` equivalents for positioned readsNiklas Fiekas-0/+89
Adds the following items under the `read_buf_at` feature: - `std::os::unix::fs::FileExt::read_buf_at` - `std::os::unix::fs::FileExt::read_buf_exact_at` - `std::os::windows::fs::FileExt::seek_read_buf`
2025-06-28"set by Rusts options". Remove misleading always-true if cfg!(unix). Drop ↵наб-7/+5
#![feature(rustc_private)]
2025-04-23Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`Jiahao XU-0/+36
Tracking issue #139324 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-27Overhaul examples for PermissionsExtMarijn Schouten-49/+75
This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2024-11-28Rollup merge of #129409 - grinapo:patch-1, r=AmanieuGuillaume Gomez-0/+5
Expand std::os::unix::fs::chown() doc with a warning Include warning about losing setuid/gid when chowning, per POSIX. It is about the underlying system call but it is rather useful to mention it in the help in case someone accidentally forgets (don't look at me :)).
2024-11-14Remove one stray space.Peter Gervai-1/+1
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-1/+1
2024-09-19[Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of ↵GnomedDev-0/+1
path
2024-08-22Update chown help with a link and adding cap warningPeter Gervai-1/+2
Linked to chown(2) manpage on the web which expands on chown call behaviour.
2024-08-22Expand std::os::unix::fs::chown() doc with a warningPeter Gervai-0/+4
Include warning about losing setuid/gid when chowning, per POSIX.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-24Add chroot unsupported implementation for VxWorksB I Mohammed Abbas-1/+1
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-9/+2
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-1/+0
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2023-12-24Fix doc typo for read_exact_atAlexBuz-1/+1
2023-09-16Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnayMatthias Krüger-1/+1
fix std::primitive doc: homogenous -> homogeneous replace "homogenous" with the more commonly used "homogeneous".
2023-09-03Use std::io::Error::is_interrupted everywhereBen Kimock-2/+2
2023-08-29fix a doc typo at std::os::unix::fs::FileExt::write_atMeng Xiangzhuo-1/+1
2023-08-22Replace version placeholders with 1.73.0Mark Rousskov-3/+3
2023-07-22Rollup merge of #113876 - darklyspaced:master, r=cuviperMatthias Krüger-1/+30
fix docs & example for `std::os::unix::prelude::FileExt::write_at` Changelog: * used `File::create` instead of `File::read` to get a writeable file * explicity mentioned the bug with `pwrite64` in docs Unfortunately, I don't think that there is really much we can do about this since the feature has already been stabilised. We could potentially add a clippy lint warning people on Linux that using `write_at` with the `O_APPEND` flag does not exhibit the behaviour that they would have assumed. fixes #113627
2023-07-20added a problematic exampledarklyspaced-3/+25
2023-07-20fix docs & example for FileExt::write_atdarklyspaced-1/+8
2023-06-25Stabilize chown functions (`unix_chown`)Yuki Okushi-6/+3
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-05-07enable `rust_2018_idioms` for doctestsozkanonur-1/+1
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-03-02Add basic testsBenoît du Garreau-0/+4
2023-03-02Take shared references as parameterBenoît du Garreau-12/+4
2023-02-27Add vectored positioned I/O on UnixBenoît du Garreau-0/+34
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-2/+2
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-02-10Implement `AsFd` for `&T` and `&mut T`.Dan Gohman-1/+1
Add implementations of `AsFd` for `&T` and `&mut T`, so that users can write code like this: ```rust pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> { ``` with `fd: F` rather than `fd: &F`. And similar for `AsHandle` and `AsSocket` on Windows. Also, adjust the `fchown` example to pass the file by reference. The code can work either way now, but passing by reference is more likely to be what users will want to do. This is an alternative to #93869, and is a simpler way to achieve the same goals: users don't need to pass borrowed-`BorrowedFd` arguments, and it prevents a pitfall in the case where users write `fd: F` instead of `fd: &F`.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-3/+3
2021-09-19Rollup merge of #89051 - schctl:master, r=jyn514Yuki Okushi-1/+3
Add intra-doc links and small changes to `std::os` to be more consistent I believe that a few items in `std::os` should be linked. I've also added a basic example in `std::os::windows`.
2021-09-17modify std::os docs to be more consistentSachin Cherian-1/+3
> add intra doc links > add a usage example for the os::windows module
2021-09-15Add tracking issue for unix_chownJosh Triplett-3/+3
2021-09-14Add chown functions to std::os::unix::fs to change the owner and group of filesJosh Triplett-0/+70
This is a straightforward wrapper that uses the existing helpers for C string handling and errno handling. Having this available is convenient for UNIX utility programs written in Rust, and avoids having to call unsafe functions like `libc::chown` directly and handle errors manually, in a program that may otherwise be entirely safe code. In addition, these functions provide a more Rustic interface by accepting appropriate traits and using `None` rather than `-1`.
2021-08-19Stabilize std::os::unix::fs::chrootJosh Triplett-2/+1
2021-07-06Rollup merge of #83581 - arennow:dir_entry_ext_unix_borrow_name, r=m-ou-seYuki Okushi-0/+39
Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr Greetings! This is my first PR here, so please forgive me if I've missed an important step or otherwise done something wrong. I'm very open to suggestions/fixes/corrections. This PR adds a function that allows `std::fs::DirEntry` to vend a borrow of its filename on Unix platforms, which is especially useful for sorting. (Windows has (as I understand it) encoding differences that require an allocation.) This new function sits alongside the cross-platform [`file_name(&self) -> OsString`](https://doc.rust-lang.org/std/fs/struct.DirEntry.html#method.file_name) function. I pitched this idea in an [internals thread](https://internals.rust-lang.org/t/allow-std-direntry-to-vend-borrows-of-its-filename/14328/4), and no one objected vehemently, so here we are. I understand features in general, I believe, but I'm not at all confident that my whole-cloth invention of a new feature string (as required by the compiler) was correct (or that the name is appropriate). Further, there doesn't appear to be a test for the sibling `ino` function, so I didn't add one for this similarly trivial function either. If it's desirable that I should do so, I'd be happy to [figure out how to] do that. The following is a trivial sample of a use-case for this function, in which directory entries are sorted without any additional allocations: ```rust use std::os::unix::fs::DirEntryExt; use std::{fs, io}; fn main() -> io::Result<()> { let mut entries = fs::read_dir(".")?.collect::<Result<Vec<_>, io::Error>>()?; entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref())); for p in entries { println!("{:?}", p); } Ok(()) } ```
2021-07-05Enable dir_entry_ext2 feature in doc test.Mara Bos-0/+1
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-05-21Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStrAaron Rennow-0/+38
DirEntryExt2 is a new trait with the same purpose as DirEntryExt, but sealed
2021-05-20Not implement `os::unix::fs::chroot` for `vxworks`Christiaan Dirkx-1/+1
2021-05-03Move `std::sys::unix::ext` to `std::os::unix`Christiaan Dirkx-0/+912