about summary refs log tree commit diff
path: root/library/std/src/path
AgeCommit message (Collapse)AuthorLines
2025-01-26Move std::path unit tests to integration testsbjorn3-2079/+0
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-3/+1
2024-11-12Make `CloneToUninit` dyn-compatibleZachary S-2/+2
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-5/+11
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+19
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+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-07Rollup merge of #127297 - the8472:path-new-hash, r=NilstriebMatthias Krüger-0/+35
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-05add unit tests for extra extension featuretison-0/+74
Signed-off-by: tison <wander4096@gmail.com>
2024-07-03Add more test cases for path comparisonsZanie Blue-0/+28
2024-07-03Add test case demonstrating equality of paths "foo/bar" and "foobar"Zanie Blue-0/+7
2024-06-06fixed memory leaks in PathBuf::leak & OsString::leak testsschvv31n-1/+4
2024-06-04impl OsString::leak & PathBuf::leakschvv31n-0/+7
2024-05-13Panic if `PathBuf::set_extension` would add a path separatorTobias Bucher-0/+23
This is likely never intended and potentially a security vulnerability if it happens. I'd guess that it's mostly literal strings that are passed to this function in practice, so I'm guessing this doesn't break anyone. CC #125060
2023-12-10remove redundant importssurechen-3/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-02Move RandomState and DefaultHasher into std::hash, but don't export for nowltdk-4/+2
2023-07-14std: add tests for `Path::with_extension`João M. Bezerra-5/+45
2022-08-18make many std tests work in MiriRalf Jung-0/+5
2022-05-16Allow `unused_macro_rules` in path testsRaoul Strackx-0/+1
2022-04-17Improve Windows path prefix parsingdylni-6/+6
2022-03-19Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnayDylan DPC-7/+7
Relax tests for Windows dos device names Windows 11 no longer turn paths ending with dos device names into device paths. E.g. `C:\path\to\COM1.txt` used to get turned into `\\.\COM1`. Whereas now this path is left as is. Note though that if the given path is an exact (case-insensitive) match for the string `COM1` then it'll still be converted to `\\.\COM1`.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-11/+11
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-05Use as_os_str to compare exact pathsChris Denton-3/+6
2022-03-05Relax tests for Windows dos device namesChris Denton-4/+1
Windows 11 no longer turn paths ending with dos device names into device paths. E.g. `C:\path\to\COM1.txt` used to get turned into `\\.\COM1`. Whereas now the path is left as is.
2022-03-05Use `as_os_str` to compare exact pathsChris Denton-7/+10
2022-03-05Unix `path::absolute`: Fix leading "." componentChris Denton-0/+5
Testing leading `.` and `..` components were missing from the unix tests.
2022-02-13Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrumbors-0/+58
`std::path::absolute` Implements #59117 by adding a `std::path::absolute` function that creates an absolute path without reading the filesystem. This is intended to be a drop-in replacement for [`std::fs::canonicalize`](https://doc.rust-lang.org/std/fs/fn.canonicalize.html) in cases where it isn't necessary to resolve symlinks. It can be used on paths that don't exist or where resolving symlinks is unwanted. It can also be used to avoid circumstances where `canonicalize` might otherwise fail. On Windows this is a wrapper around [`GetFullPathNameW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew). On Unix it partially implements the POSIX [pathname resolution](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13) specification, stopping just short of actually resolving symlinks.
2022-02-08`std::path::absolute`Chris Denton-0/+58
2022-02-06Fix hashing for windows paths containing a CurDir componentThe 8472-0/+35
* the logic only checked for / but not for \ * verbatim paths shouldn't skip items at all since they don't get normalized * the extra branches get optimized out on unix since is_sep_byte is a trivial comparison and is_verbatim is always-false * tests lacked windows coverage for these cases That lead to equal paths not having equal hashes and to unnecessary collisions.
2021-11-09add benchmarks and tests for Hash and Eq impls on PathThe8472-2/+78
The tests check for consistency between Ord, Eq and Hash
2021-10-14Ensure that pushing empty path works as beforeSean Young-0/+1
Fixes: https://github.com/rust-lang/rust/issues/89658
2021-10-01path.push() should work as expected on windows verbatim pathsSean Young-0/+9
2021-08-22Auto merge of #85166 - mbhall88:file-prefix, r=dtolnaybors-87/+310
add file_prefix method to std::path This is an initial implementation of `std::path::Path::file_prefix`. It is effectively a "left" variant of the existing [`file_stem`](https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem) method. An illustration of the difference is ```rust use std::path::Path; let path = Path::new("foo.tar.gz"); assert_eq!(path.file_stem(), Some("foo.tar")); assert_eq!(path.file_prefix(), Some("foo")); ``` In my own development, I generally find I almost always want the prefix, rather than the stem, so I thought it might be best to suggest it's addition to libstd. Of course, as this is my first contribution, I expect there is probably more work that needs to be done. Additionally, if the libstd team feel this isn't appropriate then so be it. There has been some [discussion about this on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/file_lstem/near/238076313) and a user there suggested I open a PR to see whether someone in the libstd team thinks it is worth pursuing.
2021-08-17remove unnecessary empty checkMichael Hall-0/+4
2021-07-06add Ord tests for Path comparisonsThe8472-0/+17
2021-07-06optimize {Path,PathBuf,Components}::{cmp,partial_cmp} for shared prefixesThe8472-0/+51
2021-06-15add explicit hidden file name testsMichael Hall-0/+26
2021-05-11add missing windows testsMichael Hall-53/+140
2021-05-11add file_prefix methodMichael Hall-34/+140
2020-11-07Refactor `parse_prefix` on WindowsChristiaan Dirkx-4/+4
Refactor `get_first_two_components` to `get_next_component`. Fixes the following behaviour of `parse_prefix`: - series of separator bytes in a prefix are correctly parsed as a single separator - device namespace prefixes correctly recognize both `\\` and `/` as separators
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-0/+1394
Also doing fmt inplace as requested.