>> Because in Python, we want to be able to access all files on disk.
>> Neither Java nor Mono are capable of doing that.
> 
> Java is not capable of doing that.  Mono, as I keep pointing out, is. It
> uses NULLs to escape invalid UNIX filenames.  Please see:
> 
> http://go-mono.com/docs/index.aspx?link=T%3AMono.Unix.UnixEncoding
> 
> "The upshot to all this is that Mono.Unix and Mono.Unix.Native can list,
> access, and open all files on your filesystem, regardless of encoding."

I think this is misleading. With Mono 2.0.1, I get

** (/tmp/a.exe:30553): WARNING **: FindNextFile: Bad encoding for
'/home/martin/work/3k/t/\xff'
Consider using MONO_EXTERNAL_ENCODINGS

when running the program

using System.IO;
class X{
  public static void Main(string[] args){
    DirectoryInfo di = new DirectoryInfo(".");
    foreach(FileInfo fi in di.GetFiles())
      System.Console.WriteLine("Next:"+fi.Name);
  }
}

On the other hand, when I write

using Mono.Unix;
class X{
  public static void Main(string[] args){
    UnixDirectoryInfo di = new UnixDirectoryInfo(".");
    foreach(UnixFileSystemInfo fi in di.GetFileSystemEntries())
      System.Console.WriteLine("Next:"+fi.Name);
  }
}

I get indeed all files listed (and can also find out the other
stat results). Of course, the resulting application will be
mono-specific (it links with Mono.Posix), and not work on Microsoft
.NET anymore. IOW, IronPython likely won't use this API.

Python, of course, already has the equivalent of that: os.listdir,
with a byte parameter, will give you access to all files. If
you wanted to closely emulate the Mono API, you could set
the file system encoding to the mono-lookalike codec.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to