Browse Source

2002-03-31 Dick Porter <[email protected]>

	* Directory.cs: Strip out "." and ".." from returned list

	* FileAttributes.cs: Get the right enum values

svn path=/trunk/mcs/; revision=3522
Dick Porter 24 years ago
parent
commit
b4fb31a53c

+ 6 - 0
mcs/class/corlib/System.IO/ChangeLog

@@ -1,3 +1,9 @@
+2002-03-31  Dick Porter  <[email protected]>
+
+	* Directory.cs: Strip out "." and ".." from returned list
+
+	* FileAttributes.cs: Get the right enum values
+
 2002-03-28  Dietmar Maurer  <[email protected]>
 
 	* TextWriter.cs (write): added check for null

+ 10 - 1
mcs/class/corlib/System.IO/Directory.cs

@@ -212,7 +212,16 @@ namespace System.IO
 			ArrayList entries = new ArrayList ();
 
 			while (true) {
-				if ((stat.Attributes & mask) == attrs && search.IsMatch (stat.Name))
+				// Ignore entries of "." and ".." -
+				// the documentation doesn't mention
+				// it (surprise!) but empirical
+				// testing indicates .net never
+				// returns "." or ".." in a
+				// GetDirectories() list.
+				if ((stat.Attributes & mask) == attrs &&
+				    search.IsMatch (stat.Name) &&
+				    stat.Name != "." &&
+				    stat.Name != "..")
 					entries.Add (Path.Combine (path, stat.Name));
 
 				if (!MonoIO.FindNextFile (find, out stat))

+ 15 - 14
mcs/class/corlib/System.IO/FileAttributes.cs

@@ -13,22 +13,23 @@
 namespace System.IO
 {
 	[Flags]
+	[Serializable]
 	public enum FileAttributes : int
 	{
-		Archive,
-		Compressed, 
-		Device, // Reserved for future use. 
-		Directory,
-		Encrypted,
-		Hidden,
-		Normal,
-		NotContentIndexed,
-		Offline,
-		ReadOnly,
-		ReparsePoint,
-		SparseFile,
-		System,
-		Temporary 
+		Archive = 0x00020,
+		Compressed = 0x00800, 
+		Device = 0x00040, // Reserved for future use (NOT the w32 value). 
+		Directory = 0x00010,
+		Encrypted = 0x04000, // NOT the w32 value
+		Hidden = 0x00002,
+		Normal = 0x00080,
+		NotContentIndexed = 0x02000,
+		Offline = 0x01000,
+		ReadOnly = 0x00001,
+		ReparsePoint = 0x00400,
+		SparseFile = 0x00200,
+		System = 0x00004,
+		Temporary = 0x00100 
 	}
 
 }