-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Expand the area of std::fs #24711
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @aturon Note that this should not be merged until the RFC is approved. |
-> io::Result<()> | ||
{ | ||
sys::fs2::symlink_inner(src.as_ref(), dst.as_ref(), true) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you missed moving the new symlink APIs when breaking these modules out into separate files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! I had a feeling I shouldn't have ignored that merge conflict.
4327621
to
791156a
Compare
Thanks for the info! I'm moving discussion out here as your comment is now collapsed. This actually poses some difficulties and the current solution makes me feel uncomfortable. There are currently two methods of acquiring a There are a few places which we can get a
Overall this basically means that we need to have an extra syscall or some different semantics (which now makes me worry about Regardless, though, I think the current implementation is at least "more correct", although I'm not convinced that we actually want it! |
I think that the latest approach that you've added looks fine, and I think that the abstraction is reasonable; having to spend an extra syscall to find out if a file is a symlink or not doesn't seem unreasonable, especially since you only pay that extra cost for reparse points, which should be fairly rare. And I think your current approach is fine, you're right, there are some concerns using On the other hand, I'm not a Windows expert; I just noticed the problem since I'd been reading the documentation closely while reviewing rust-lang/rfcs#1044 and writing rust-lang/rfcs#1048. @retep998 do you have any opinion on this, you seem to have the most Windows API experience? |
As long as we're only doing that extra syscall for reparse points, the cost should be negligible since most files are not reparse points. That said, the implementation of invoking |
☔ The latest upstream changes (presumably #24724) made this pull request unmergeable. Please resolve the merge conflicts. |
self.root.join(&self.file_name()) | ||
} | ||
|
||
pub fn file_name(&self) -> OsString { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I pointed out in the RFC (a little lately, sorry for that). If the entry is a directory or something else, is file_name is still a good method name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the file_name
methods of Path
, which was the source for this name. The directory/file distinction here is known to not apply much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really fine with that. I find it not clear. It's really a shame that I was aware of the RFC so lately...
|
||
/// Return the metadata for the file that this entry points at. | ||
/// | ||
/// This function may not require an extra system call on some platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: "This function may require an extra system call on some platforms" (or, better yet: we could go ahead and add the # Platform behavior
section and give a fuller breakdown).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I've started out with the platform behavior sections to see where it takes us.
c657c08
to
92eae9b
Compare
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: rust-lang/rfcs#1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`.
@aturon I actually forgot that I didn't implement |
@alexcrichton Lovely! @bors: r+ |
📌 Commit ebc2440 has been approved by |
⌛ Testing commit ebc2440 with merge a23c862... |
💔 Test failed - auto-win-64-nopt-t |
This is the last remaining portion of rust-lang#24796
⌛ Testing commit 0368abb with merge e3c5027... |
💔 Test failed - auto-linux-32-nopt-t |
@bors: retry On Wed, Apr 29, 2015 at 12:22 AM, bors notifications@github.com wrote:
|
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: rust-lang/rfcs#1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`. Closes #24796
💔 Test failed - auto-linux-32-opt |
@bors: retry On Wed, Apr 29, 2015 at 10:48 AM, bors notifications@github.com wrote:
|
⚡ Previous build results for auto-linux-64-nopt-t, auto-mac-64-opt, auto-win-64-nopt-t are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-opt, auto-linux-64-x-android-t, auto-mac-32-opt, auto-mac-64-nopt-t, auto-win-32-nopt-t, auto-win-32-opt, auto-win-64-opt... |
💔 Test failed - auto-linux-32-nopt-t |
@bors: retry On Wed, Apr 29, 2015 at 1:16 PM, bors notifications@github.com wrote:
|
⚡ Previous build results for auto-linux-64-nopt-t, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-64-nopt-t are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-opt, auto-linux-64-x-android-t, auto-mac-32-opt, auto-win-32-nopt-t, auto-win-32-opt, auto-win-64-opt... |
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: rust-lang/rfcs#1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`. Closes rust-lang#24796
⛄ The build was interrupted to prioritize another pull request. |
⚡ Previous build results for auto-linux-64-nopt-t, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-64-nopt-t are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-opt, auto-linux-64-x-android-t, auto-mac-32-opt, auto-win-32-nopt-t, auto-win-32-opt, auto-win-64-opt... |
⛄ The build was interrupted to prioritize another pull request. |
This commit is an implementation of RFC 1044 which adds additional
surface area to the
std::fs
module. All new APIs are#[unstable]
behindassorted feature names for each one.
The new APIs added are:
fs::canonicalize
- bindings torealpath
on unix andGetFinalPathNameByHandle
on windows.fs::symlink_metadata
- similar tolstat
on unixfs::FileType
and accessor methods asis_{file,dir,symlink}
fs::Metadata::file_type
- accessor for the raw file typefs::DirEntry::metadata
- acquisition of metadata which is free on Windowsbut requires a syscall on unix.
fs::DirEntry::file_type
- access the file type which may not require asyscall on most platforms.
fs::DirEntry::file_name
- access just the file name without leadingcomponents.
fs::PathExt::symlink_metadata
- convenience method for the top-levelfunction.
fs::PathExt::canonicalize
- convenience method for the top-levelfunction.
fs::PathExt::read_link
- convenience method for the top-levelfunction.
fs::PathExt::read_dir
- convenience method for the top-levelfunction.
std::os::raw
- type definitions for raw OS/C types available on allplatforms.
std::os::$platform
- new modules have been added for all currently supportedplatforms (e.g. those more specific than just
unix
).std::os::$platform::raw
- platform-specific type definitions. These modulesare populated with the bare essentials necessary for lowing I/O types into
their raw representations, and currently largely consist of the
stat
definition for unix platforms.
This commit also deprecates
Metadata::{modified, accessed}
in favor ofinspecting the raw representations via the lowering methods of
Metadata
.Closes #24796