about summary refs log tree commit diff
path: root/library/std/src/path.rs
AgeCommit message (Collapse)AuthorLines
2025-07-07std: fix typo in `std::path`xizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-02Rollup merge of #141847 - xizheyin:141837, r=jhprattMatthias Krüger-2/+4
Explain `TOCTOU` on the top of `std::fs`, and reference it in functions Fixes rust-lang/rust#141837 r? ``````@workingjubilee``````
2025-07-01Update version placeholdersJosh Stone-1/+1
2025-06-19Auto merge of #141864 - Berrysoft:cygwin-path, r=ChrisDentonbors-1/+16
Handle win32 separator for cygwin paths This PR handles a issue that cygwin actually supports Win32 path, so we need to handle the Win32 prefix and separaters. r? `@mati865` cc `@jeremyd2019` ~~Not sure if I should handle the prefix like the windows target... Cygwin *does* support win32 paths directly going through the APIs, but I think it's not the recommended way.~~ Here I just use `cygwin_conv_path` because it handles both cygwin and win32 paths correctly and convert them into absolute POSIX paths. UPDATE: Windows path prefix is handled.
2025-06-16Add documentation for `PathBuf`'s `FromIterator` and `Extend` implsYotam Ofek-0/+27
2025-06-16Handle win32 separator & prefixes for cygwin paths王宇逸-1/+16
2025-06-06Stabilised `os_string_pathbuf_leak`schvv31n-1/+1
2025-06-04Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=AmanieuMatthias Krüger-1/+2
make `OsString::new` and `PathBuf::new` unstably const Since #129041, `String::into_bytes` is `const`, which allows making `OsString::new` and `PathBuf::new` unstably const now. Not sure what the exact process for this is; does it need an ACP?
2025-06-02Explain TOCTOU on the top of `std::fs`, and ref it in functionsxizheyin-2/+4
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-29Rollup merge of #141477 - tshepang:patch-1, r=ChrisDentonJacob Pratt-5/+20
Path::with_extension: show that it adds an extension where one did no… …t exist I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions. Also, this replaced example already has a similar example below.
2025-05-25Implement normalize lexicallyChris Denton-0/+77
2025-05-24make `OsString::new` and `PathBuf::new` unstably constcyrgani-1/+2
2025-05-24reduce clutter... too many importsTshepang Mbambo-8/+8
2025-05-24Path::with_extension: improve examplesTshepang Mbambo-1/+16
2025-05-20use Self alias in self types rather than manually substituting itMichael Goulet-1/+1
2025-05-02Rollup merge of #140159 - thaliaarchi:pathbuf-extension, r=workingjubileeStuart Cook-7/+12
Avoid redundant WTF-8 checks in `PathBuf` Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings. To assist in this, mark the internal methods `OsString::truncate` and `extend_from_slice` as `unsafe` to communicate their safety invariants better than with module privacy. Similar to #137777. cc `@joboet` `@ChrisDenton`
2025-04-30Avoid redundant WTF-8 checks in `PathBuf`Thalia Archibald-6/+10
Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings.
2025-04-30Make internal `OsString::truncate` and `extend_from_slice` unsafeThalia Archibald-1/+2
Communicate the safety invariants of these methods with `unsafe fn` rather than privacy.
2025-04-22Validate extension in `PathBuf::add_extension`Thalia Archibald-7/+17
The extension is validated in `PathBuf::set_extension`, but not `add_extension`. Fix that. Check for both / and \ path separators on Windows, even when the path is verbatim, since this is logically like `PathBuf::push` which normalizes separators (i.e., keeping the current behavior).
2025-04-21cleanup redundant pattern instancesJonathan Gruner-1/+1
2025-03-13Remove has_redox_schemebjorn3-7/+1
Redox OS is moving away from name:/path style paths to /scheme/name/path style paths which are already handled correctly without has_redox_scheme.
2025-02-10Fix &&str and trailing commas in io::const_error!Thalia Archibald-1/+1
2025-01-26Move std::path unit tests to integration testsbjorn3-3/+0
2025-01-13path: Move is_absolute check to sys::pathAyush Singh-11/+4
I am working on fs support for UEFI [0], which similar to windows has prefix components, but is not quite same as Windows. It also seems that Prefix is tied closely to Windows and cannot really be extended [1]. This PR just tries to remove coupling between Prefix and absolute path checking to allow platforms to provide there own implementation to check if a path is absolute or not. I am not sure if any platform other than windows currently uses Prefix, so I have kept the path.prefix().is_some() check in most cases. [0]: https://github.com/rust-lang/rust/pull/135368 [1]: https://github.com/rust-lang/rust/issues/52331#issuecomment-2492796137 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2024-12-13Fix `Path::is_absolute` on HermitMartin Kröning-1/+3
2024-12-01Rollup merge of #133602 - SanchithHegde:fix-pathbuf-example-codeblocks, ↵Matthias Krüger-0/+2
r=cuviper fix: fix codeblocks in `PathBuf` example This PR adds missing codeblocks around an example included in the `PathBuf` documentation.
2024-11-29fix: fix codeblocks in `PathBuf` exampleSanchith Hegde-0/+2
2024-11-27replace placeholder versionBoxy-3/+3
2024-11-27Rollup merge of #133449 - joboet:io_const_error, r=tgross35Matthias Krüger-1/+1
std: expose `const_io_error!` as `const_error!` ACP: https://github.com/rust-lang/libs-team/issues/205 Tracking issue: https://github.com/rust-lang/rust/issues/133448 Probably best reviewed commit-by-commit, the first one does the API change, the second does the mass-rename.
2024-11-26std: update internal uses of `io::const_error!`joboet-1/+1
2024-11-24Added a doc test for std::path::strip_prefixCrom (Thibaut CHARLES)-0/+1
2024-11-12Make `CloneToUninit` dyn-compatibleZachary S-4/+4
2024-10-29Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`Eduardo Sánchez Muñoz-0/+28
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-2/+2
2024-09-25Use `&raw` in the standard libraryJosh Stone-1/+1
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-19[Clippy] Swap `manual_main_separator_str` to use diagnostic item instead of pathGnomedDev-0/+1
2024-09-19[Clippy] Swap `redundant_clone` to use diagnostic items instead of pathsGnomedDev-0/+1
2024-09-19[Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of pathsGnomedDev-0/+1
2024-09-11Fixup docs for PathBufJubilee Young-2/+2
2024-09-11Expand PathBuf documentationChris Jefferson-0/+24
Mention that some methods do not sanitize their input fully
2024-09-05fix: correct {Path,OsStr}::to_string_lossy() docsRyosuke Takahashi-1/+1
2024-07-29Sparkle some attributes over `CloneToUninit` stuffPavel Grigorenko-0/+1
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+11
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-1/+1
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-22Fix some `#[cfg_attr(not(doc), repr(..))]`Pavel Grigorenko-4/+2
Now that #90435 seems to have been resolved.
2024-07-07Rollup merge of #127297 - the8472:path-new-hash, r=NilstriebMatthias Krüger-4/+9
Improve std::Path's Hash quality by avoiding prefix collisions This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes. The tests are from #127255 Closes #127254
2024-07-05update commentstison-4/+1
Signed-off-by: tison <wander4096@gmail.com>
2024-07-03impl PathBuf::add_extension and Path::with_added_extensiontison-0/+97
Signed-off-by: tison <wander4096@gmail.com>