]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/back/msvc/registry.rs
Fix Windows
[rust.git] / src / librustc_trans / back / msvc / registry.rs
index 63fb19c9772a82a0f1d74b2d5ad7bef38d83944f..8242f53896afc6c762a3ff2ef84edf62295456de 100644 (file)
 use std::io;
 use std::ffi::{OsString, OsStr};
 use std::os::windows::prelude::*;
-use std::ops::RangeFrom;
 use std::ptr;
-use libc::{c_void, c_long};
+use libc::c_long;
 
-type DWORD = u32;
+pub type DWORD = u32;
 type LPCWSTR = *const u16;
 type LONG = c_long;
 type LPDWORD = *mut DWORD;
 const SYNCHRONIZE: REGSAM = 0x00100000;
 const REG_SZ: DWORD = 1;
 const ERROR_SUCCESS: i32 = 0;
-const ERROR_NO_MORE_ITEMS: DWORD = 259;
 
-enum __HKEY__ {}
+pub enum __HKEY__ {}
 pub type HKEY = *mut __HKEY__;
 pub type PHKEY = *mut HKEY;
 pub type REGSAM = DWORD;
-pub type LPWSTR = *mut u16;
-pub type PFILETIME = *mut c_void;
 
 #[link(name = "advapi32")]
 extern "system" {
@@ -56,14 +52,6 @@ fn RegQueryValueExW(hKey: HKEY,
                         lpType: LPDWORD,
                         lpData: LPBYTE,
                         lpcbData: LPDWORD) -> LONG;
-    fn RegEnumKeyExW(hKey: HKEY,
-                     dwIndex: DWORD,
-                     lpName: LPWSTR,
-                     lpcName: LPDWORD,
-                     lpReserved: LPDWORD,
-                     lpClass: LPWSTR,
-                     lpcClass: LPDWORD,
-                     lpftLastWriteTime: PFILETIME) -> LONG;
     fn RegCloseKey(hKey: HKEY) -> LONG;
 }
 
@@ -76,11 +64,6 @@ enum Repr {
     Owned(OwnedKey),
 }
 
-pub struct Iter<'a> {
-    idx: RangeFrom<DWORD>,
-    key: &'a RegistryKey,
-}
-
 unsafe impl Sync for RegistryKey {}
 unsafe impl Send for RegistryKey {}
 
@@ -108,10 +91,6 @@ pub fn open(&self, key: &OsStr) -> io::Result<RegistryKey> {
         }
     }
 
-    pub fn iter(&self) -> Iter {
-        Iter { idx: 0.., key: self }
-    }
-
     pub fn query_str(&self, name: &str) -> io::Result<OsString> {
         let name: &OsStr = name.as_ref();
         let name = name.encode_wide().chain(Some(0)).collect::<Vec<_>>();
@@ -155,25 +134,3 @@ fn drop(&mut self) {
         unsafe { RegCloseKey(self.0); }
     }
 }
-
-impl<'a> Iterator for Iter<'a> {
-    type Item = io::Result<OsString>;
-
-    fn next(&mut self) -> Option<io::Result<OsString>> {
-        self.idx.next().and_then(|i| unsafe {
-            let mut v = Vec::with_capacity(256);
-            let mut len = v.capacity() as DWORD;
-            let ret = RegEnumKeyExW(self.key.raw(), i, v.as_mut_ptr(), &mut len,
-                                    ptr::null_mut(), ptr::null_mut(), ptr::null_mut(),
-                                    ptr::null_mut());
-            if ret == ERROR_NO_MORE_ITEMS as LONG {
-                None
-            } else if ret != ERROR_SUCCESS {
-                Some(Err(io::Error::from_raw_os_error(ret as i32)))
-            } else {
-                v.set_len(len as usize);
-                Some(Ok(OsString::from_wide(&v)))
-            }
-        })
-    }
-}