[Mono-bugs] [Bug 65727][Nor] Changed - DirectoryInfo.GetFiles() doesn't correctly return a funky filename

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 13 Sep 2004 09:37:53 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dick@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=65727

--- shadow/65727	2004-09-10 17:29:32.000000000 -0400
+++ shadow/65727.tmp.29891	2004-09-13 09:37:52.000000000 -0400
@@ -1,14 +1,14 @@
 Bug#: 65727
 Product: Mono: Class Libraries
 Version: unspecified
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: CORLIB
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: joeshaw@novell.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -21,6 +21,64 @@
 but when I tab complete it in bash I get "Icon^M".  In nautilus sometimes
 it shows a linebreak and sometimes the unicode value.
 
 Anyway, when I iterate across the return values of GetFiles(), the
 character is stripped out, leaving me with "Icon", which when you later try
 to do File.Exists() on it returns false.
+
+------- Additional Comments From dick@ximian.com  2004-09-13 09:37 -------
+Interesting.  The underlying code has the following algorithm:
+
+Scan the directory using g_dir_open(), g_dir_read_name() and wildcard
+pattern matching with g_pattern_match_string().
+
+For each entry,
+. lstat it, and if its a dangling symlink ignore it.
+. ensure the name is valid UTF-8 (maybe converting it from another
+encoding if the MONO_EXTERNAL_ENCODINGS variable is set.)  If it's not
+valid UTF-8, ignore it.
+. fill in the data and return it.
+
+
+
+Do you have a small test case?  I tried to reproduce your problem here
+and it works for me.
+
+:; cat list.cs      
+
+using System;
+using System.IO;
+
+public class foo {
+        public static void Main() {
+                string[] files = Directory.GetFiles("/tmp/joe");
+
+                foreach (string file in files) {
+                        Console.WriteLine("Found [{0}]", file);
+                }
+        }
+}
+
+
+gives:  
+
+[dick@hagbard joe] [ 2:11] 
+:; touch Icon^M
+
+[dick@hagbard joe] [ 2:11] 
+:; ls
+Icon?  a  b  c  list.cs  list.exe
+
+[dick@hagbard joe] [ 2:11] 
+:; mono list.exe
+]ound [/tmp/joe/Icon
+Found [/tmp/joe/a]
+Found [/tmp/joe/b]
+Found [/tmp/joe/c]
+Found [/tmp/joe/list.cs]
+Found [/tmp/joe/list.exe]
+
+
+(note the carriage return on the top line)
+
+
+