Auto merge of #26102 - retep998:openoptionsext, r=alexcrichton
r? @alexcrichton
This commit is contained in:
@@ -25,41 +25,41 @@ use sys_common::{AsInnerMut, AsInner};
|
|||||||
pub trait OpenOptionsExt {
|
pub trait OpenOptionsExt {
|
||||||
/// Overrides the `dwDesiredAccess` argument to the call to `CreateFile`
|
/// Overrides the `dwDesiredAccess` argument to the call to `CreateFile`
|
||||||
/// with the specified value.
|
/// with the specified value.
|
||||||
fn desired_access(&mut self, access: i32) -> &mut Self;
|
fn desired_access(&mut self, access: u32) -> &mut Self;
|
||||||
|
|
||||||
/// Overrides the `dwCreationDisposition` argument to the call to
|
/// Overrides the `dwCreationDisposition` argument to the call to
|
||||||
/// `CreateFile` with the specified value.
|
/// `CreateFile` with the specified value.
|
||||||
///
|
///
|
||||||
/// This will override any values of the standard `create` flags, for
|
/// This will override any values of the standard `create` flags, for
|
||||||
/// example.
|
/// example.
|
||||||
fn creation_disposition(&mut self, val: i32) -> &mut Self;
|
fn creation_disposition(&mut self, val: u32) -> &mut Self;
|
||||||
|
|
||||||
/// Overrides the `dwFlagsAndAttributes` argument to the call to
|
/// Overrides the `dwFlagsAndAttributes` argument to the call to
|
||||||
/// `CreateFile` with the specified value.
|
/// `CreateFile` with the specified value.
|
||||||
///
|
///
|
||||||
/// This will override any values of the standard flags on the
|
/// This will override any values of the standard flags on the
|
||||||
/// `OpenOptions` structure.
|
/// `OpenOptions` structure.
|
||||||
fn flags_and_attributes(&mut self, val: i32) -> &mut Self;
|
fn flags_and_attributes(&mut self, val: u32) -> &mut Self;
|
||||||
|
|
||||||
/// Overrides the `dwShareMode` argument to the call to `CreateFile` with
|
/// Overrides the `dwShareMode` argument to the call to `CreateFile` with
|
||||||
/// the specified value.
|
/// the specified value.
|
||||||
///
|
///
|
||||||
/// This will override any values of the standard flags on the
|
/// This will override any values of the standard flags on the
|
||||||
/// `OpenOptions` structure.
|
/// `OpenOptions` structure.
|
||||||
fn share_mode(&mut self, val: i32) -> &mut Self;
|
fn share_mode(&mut self, val: u32) -> &mut Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpenOptionsExt for OpenOptions {
|
impl OpenOptionsExt for OpenOptions {
|
||||||
fn desired_access(&mut self, access: i32) -> &mut OpenOptions {
|
fn desired_access(&mut self, access: u32) -> &mut OpenOptions {
|
||||||
self.as_inner_mut().desired_access(access); self
|
self.as_inner_mut().desired_access(access); self
|
||||||
}
|
}
|
||||||
fn creation_disposition(&mut self, access: i32) -> &mut OpenOptions {
|
fn creation_disposition(&mut self, access: u32) -> &mut OpenOptions {
|
||||||
self.as_inner_mut().creation_disposition(access); self
|
self.as_inner_mut().creation_disposition(access); self
|
||||||
}
|
}
|
||||||
fn flags_and_attributes(&mut self, access: i32) -> &mut OpenOptions {
|
fn flags_and_attributes(&mut self, access: u32) -> &mut OpenOptions {
|
||||||
self.as_inner_mut().flags_and_attributes(access); self
|
self.as_inner_mut().flags_and_attributes(access); self
|
||||||
}
|
}
|
||||||
fn share_mode(&mut self, access: i32) -> &mut OpenOptions {
|
fn share_mode(&mut self, access: u32) -> &mut OpenOptions {
|
||||||
self.as_inner_mut().share_mode(access); self
|
self.as_inner_mut().share_mode(access); self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,17 +158,17 @@ impl OpenOptions {
|
|||||||
pub fn append(&mut self, append: bool) { self.append = append; }
|
pub fn append(&mut self, append: bool) { self.append = append; }
|
||||||
pub fn create(&mut self, create: bool) { self.create = create; }
|
pub fn create(&mut self, create: bool) { self.create = create; }
|
||||||
pub fn truncate(&mut self, truncate: bool) { self.truncate = truncate; }
|
pub fn truncate(&mut self, truncate: bool) { self.truncate = truncate; }
|
||||||
pub fn creation_disposition(&mut self, val: i32) {
|
pub fn creation_disposition(&mut self, val: u32) {
|
||||||
self.creation_disposition = Some(val as libc::DWORD);
|
self.creation_disposition = Some(val);
|
||||||
}
|
}
|
||||||
pub fn flags_and_attributes(&mut self, val: i32) {
|
pub fn flags_and_attributes(&mut self, val: u32) {
|
||||||
self.flags_and_attributes = Some(val as libc::DWORD);
|
self.flags_and_attributes = Some(val);
|
||||||
}
|
}
|
||||||
pub fn desired_access(&mut self, val: i32) {
|
pub fn desired_access(&mut self, val: u32) {
|
||||||
self.desired_access = Some(val as libc::DWORD);
|
self.desired_access = Some(val);
|
||||||
}
|
}
|
||||||
pub fn share_mode(&mut self, val: i32) {
|
pub fn share_mode(&mut self, val: u32) {
|
||||||
self.share_mode = Some(val as libc::DWORD);
|
self.share_mode = Some(val);
|
||||||
}
|
}
|
||||||
pub fn security_attributes(&mut self, attrs: libc::LPSECURITY_ATTRIBUTES) {
|
pub fn security_attributes(&mut self, attrs: libc::LPSECURITY_ATTRIBUTES) {
|
||||||
self.security_attributes = attrs as usize;
|
self.security_attributes = attrs as usize;
|
||||||
@@ -221,7 +221,7 @@ impl File {
|
|||||||
fn open_reparse_point(path: &Path) -> io::Result<File> {
|
fn open_reparse_point(path: &Path) -> io::Result<File> {
|
||||||
let mut opts = OpenOptions::new();
|
let mut opts = OpenOptions::new();
|
||||||
opts.read(true);
|
opts.read(true);
|
||||||
opts.flags_and_attributes(c::FILE_FLAG_OPEN_REPARSE_POINT as i32);
|
opts.flags_and_attributes(c::FILE_FLAG_OPEN_REPARSE_POINT);
|
||||||
File::open(path, &opts)
|
File::open(path, &opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user