-
Notifications
You must be signed in to change notification settings - Fork 689
Add unistd::{access, faccessat} #605
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
Conversation
src/unistd.rs
Outdated
} | ||
} | ||
|
||
pub enum AccessMode { |
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 should be documented as it's a public interface.
src/unistd.rs
Outdated
@@ -819,6 +819,64 @@ pub fn mkstemp<P: ?Sized + NixPath>(template: &P) -> Result<(RawFd, PathBuf)> { | |||
Ok((fd, PathBuf::from(pathname))) | |||
} | |||
|
|||
libc_bitflags!{ | |||
pub flags AccessFlags: c_int { |
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.
Please document this.
src/unistd.rs
Outdated
@@ -1,14 +1,14 @@ | |||
//! Safe wrappers around functions found in libc "unistd.h" header | |||
|
|||
use {Errno, Error, Result, NixPath}; | |||
use fcntl::{fcntl, OFlag, O_CLOEXEC, FD_CLOEXEC}; | |||
use fcntl::{fcntl, OFlag, AtFlags, O_CLOEXEC, FD_CLOEXEC}; |
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 should be alphabetical, so AtFlags
is first.
src/unistd.rs
Outdated
Flags(AccessFlags), | ||
} | ||
|
||
impl AccessMode { |
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 should be commented.
src/unistd.rs
Outdated
} | ||
} | ||
|
||
/// Check whether a file exists or whether the current process can access a file. |
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.
Please link to the man page for this. See the fork()
function doccomments for an example.
Errno::result(res).map(drop) | ||
} | ||
|
||
/// Check whether a file exists or whether the current process can access a file, |
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.
Please link to the man page for this. See the fork()
function doccomments for an example.
Thanks for your PR, @bugaevc! I imagine this is pretty useful. I've made some comments, mostly superficial stuff right now. I'll come back and make a deeper inspection of stuff once things are a little more comments. Also, when you make these changes, could you squash everything into 1 commit? Thanks! |
☑️ Done |
I just realized that this PR overlaps with #562, which covers a lot more ground. I'd like to close this PR in favor of that one. Would you be willing to help me review that PR and we can close this one? |
Sure -- I wonder how come I haven't noticed it myself. |
We should also add
AT_EACCESS
(and the rest ofAT_*
flags), but that's not included in this PR.