about summary refs log tree commit diff
path: root/library/std/src/path
AgeCommit message (Collapse)AuthorLines
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.