| Age | Commit message (Collapse) | Author | Lines |
|
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
|
|
Explain `TOCTOU` on the top of `std::fs`, and reference it in functions
Fixes rust-lang/rust#141837
r? ``````@workingjubilee``````
|
|
|
|
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.
|
|
|
|
|
|
|
|
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?
|
|
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
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`
|
|
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.
|
|
Communicate the safety invariants of these methods with `unsafe fn`
rather than privacy.
|
|
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).
|
|
|
|
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.
|
|
|
|
|
|
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>
|
|
|
|
r=cuviper
fix: fix codeblocks in `PathBuf` example
This PR adds missing codeblocks around an example included in the `PathBuf` documentation.
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
Mention that some methods do not sanitize their input fully
|
|
|
|
|
|
|
|
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
|
|
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
|
|
Now that #90435 seems to have been resolved.
|
|
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
|
|
Signed-off-by: tison <wander4096@gmail.com>
|
|
Signed-off-by: tison <wander4096@gmail.com>
|