Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2010-07-30 18:13:22 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2010-07-30 18:13:22 +0400
commit940155882171d68ee6678247eb2bf51a01ee0e63 (patch)
tree4bbb2ab06c343f586b34a7aeb4b69e1fc99e4783
parent3f6f46567b4e298934359607083a75e2e0a7b634 (diff)
Move subkey info routines into KeyHandler to handle volatile keys.
* UnixRegistryApi.cs: Move GetSubKeyCount and GetSubKeyNames to KeyHandler, so we can properly track volatile subkeys there *without* exposing any impl details.
-rw-r--r--mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs52
1 files changed, 43 insertions, 9 deletions
diff --git a/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs b/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs
index 6d8362776cb..6397b21ec79 100644
--- a/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs
+++ b/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs
@@ -41,6 +41,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
@@ -547,6 +548,46 @@ namespace Microsoft.Win32 {
return vals;
}
+ public int GetSubKeyCount ()
+ {
+ return GetSubKeyNames ().Length;
+ }
+
+ public string [] GetSubKeyNames ()
+ {
+ DirectoryInfo selfDir = new DirectoryInfo (ActualDir);
+ DirectoryInfo[] subDirs = selfDir.GetDirectories ();
+ string[] subKeyNames;
+
+ // for volatile keys (cannot contain non-volatile subkeys) or keys
+ // without *any* presence in the volatile key section, we can do it simple.
+ if (IsVolatile || !Directory.Exists (GetVolatileDir (Dir))) {
+ subKeyNames = new string[subDirs.Length];
+ for (int i = 0; i < subDirs.Length; i++) {
+ DirectoryInfo subDir = subDirs[i];
+ subKeyNames[i] = subDir.Name;
+ }
+ return subKeyNames;
+ }
+
+ // We may have the entries repeated, so keep just one of each one.
+ DirectoryInfo volatileDir = new DirectoryInfo (GetVolatileDir (Dir));
+ DirectoryInfo [] volatileSubDirs = volatileDir.GetDirectories ();
+ Dictionary<string,string> dirs = new Dictionary<string,string> ();
+
+ foreach (DirectoryInfo dir in subDirs)
+ dirs [dir.Name] = dir.Name;
+ foreach (DirectoryInfo volDir in volatileSubDirs)
+ dirs [volDir.Name] = volDir.Name;
+
+ subKeyNames = new string [dirs.Count];
+ int j = 0;
+ foreach (KeyValuePair<string,string> entry in dirs)
+ subKeyNames[j++] = entry.Value;
+
+ return subKeyNames;
+ }
+
//
// This version has to do argument validation based on the valueKind
//
@@ -861,7 +902,7 @@ namespace Microsoft.Win32 {
KeyHandler self = KeyHandler.Lookup (rkey, true);
if (self == null)
throw RegistryKey.CreateMarkedForDeletionException ();
- return Directory.GetDirectories (self.Dir).Length;
+ return self.GetSubKeyCount ();
}
public int ValueCount (RegistryKey rkey)
@@ -906,14 +947,7 @@ namespace Microsoft.Win32 {
public string [] GetSubKeyNames (RegistryKey rkey)
{
KeyHandler self = KeyHandler.Lookup (rkey, true);
- DirectoryInfo selfDir = new DirectoryInfo (self.Dir);
- DirectoryInfo[] subDirs = selfDir.GetDirectories ();
- string[] subKeyNames = new string[subDirs.Length];
- for (int i = 0; i < subDirs.Length; i++) {
- DirectoryInfo subDir = subDirs[i];
- subKeyNames[i] = subDir.Name;
- }
- return subKeyNames;
+ return self.GetSubKeyNames ();
}
public string [] GetValueNames (RegistryKey rkey)