summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Nelson <joshua@yottadb.com>2020-09-22 23:07:30 -0400
committerGitHub <noreply@github.com>2020-09-22 23:07:30 -0400
commit15f08d6ddfa1d6e50f783196bd63cacf7d015b3e (patch)
treef1291107956b1efec99791ccc2fa76c23a48f4a4
parentAuto merge of #76928 - lcnr:opaque-types-cache, r=tmandry (diff)
downloadrust-revert-76110-convert-openoptions-cint.tar.gz
rust-revert-76110-convert-openoptions-cint.tar.bz2
rust-revert-76110-convert-openoptions-cint.tar.xz
Revert "Function to convert OpenOptions to c_int"revert-76110-convert-openoptions-cint
-rw-r--r--library/std/src/sys/unix/ext/fs.rs29
-rw-r--r--library/std/src/sys/unix/fs.rs6
2 files changed, 0 insertions, 35 deletions
diff --git a/library/std/src/sys/unix/ext/fs.rs b/library/std/src/sys/unix/ext/fs.rs
index 83cbe25..4b9f4ce 100644
--- a/library/std/src/sys/unix/ext/fs.rs
+++ b/library/std/src/sys/unix/ext/fs.rs
@@ -348,31 +348,6 @@ pub trait OpenOptionsExt {
348 /// ``` 348 /// ```
349 #[stable(feature = "open_options_ext", since = "1.10.0")] 349 #[stable(feature = "open_options_ext", since = "1.10.0")]
350 fn custom_flags(&mut self, flags: i32) -> &mut Self; 350 fn custom_flags(&mut self, flags: i32) -> &mut Self;
351
352 /// Get the flags as [`libc::c_int`].
353 ///
354 /// This method allows the reuse of the OpenOptions as flags argument for [`libc::open`].
355 ///
356 /// [`libc::c_int`]: https://docs.rs/libc/*/libc/type.c_int.html
357 /// [`libc::open`]: https://docs.rs/libc/*/libc/fn.open.html
358 ///
359 /// # Examples
360 ///
361 /// ```no_run
362 /// # #![feature(rustc_private)]
363 /// #![feature(open_options_ext_as_flags)]
364 /// extern crate libc;
365 /// use std::ffi::CString;
366 /// use std::fs::OpenOptions;
367 /// use std::os::unix::fs::OpenOptionsExt;
368 ///
369 /// let mut options = OpenOptions::new();
370 /// options.write(true).read(true);
371 /// let file_name = CString::new("foo.txt").unwrap();
372 /// let file = unsafe { libc::open(file_name.as_c_str().as_ptr(), options.as_flags().unwrap()) };
373 /// ```
374 #[unstable(feature = "open_options_ext_as_flags", issue = "76801")]
375 fn as_flags(&self) -> io::Result<libc::c_int>;
376} 351}
377 352
378#[stable(feature = "fs_ext", since = "1.1.0")] 353#[stable(feature = "fs_ext", since = "1.1.0")]
@@ -386,10 +361,6 @@ impl OpenOptionsExt for OpenOptions {
386 self.as_inner_mut().custom_flags(flags); 361 self.as_inner_mut().custom_flags(flags);
387 self 362 self
388 } 363 }
389
390 fn as_flags(&self) -> io::Result<libc::c_int> {
391 self.as_inner().as_flags()
392 }
393} 364}
394 365
395/// Unix-specific extensions to [`fs::Metadata`]. 366/// Unix-specific extensions to [`fs::Metadata`].
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index 09954f0..566ac09 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -656,12 +656,6 @@ impl OpenOptions {
656 self.mode = mode as mode_t; 656 self.mode = mode as mode_t;
657 } 657 }
658 658
659 pub fn as_flags(&self) -> io::Result<c_int> {
660 let access_mode = self.get_access_mode()?;
661 let creation_mode = self.get_creation_mode()?;
662 Ok(creation_mode | access_mode | self.custom_flags)
663 }
664
665 fn get_access_mode(&self) -> io::Result<c_int> { 659 fn get_access_mode(&self) -> io::Result<c_int> {
666 match (self.read, self.write, self.append) { 660 match (self.read, self.write, self.append) {
667 (true, false, false) => Ok(libc::O_RDONLY), 661 (true, false, false) => Ok(libc::O_RDONLY),