[Win32utils-devel] File.nopen alpha

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Thu Nov 11 20:38:50 EST 2004


Hi,
> 
> Hi all,
> 
> I've committed an alpha version of File.nopen (native open) to
> win32-file.  This is a wrapper for CreateFile().  A quick synopsis:
> 
>  * File.nopen(file,access_mode,share_mode,creation_mode,flags)
>  * 
>  * A 'native' open method.  This uses CreateFile() behind the scenes
> instead of
>  * the _open() function.  This allows much greater flexibility when it
> comes
>  * to Windows files.  It also allows you to open directories, which
> File.open
>  * cannot do on Windows.
>  * 
>  * The access mode defaults to READ_DATA | WRITE_DATA
>  * The share mode defaults to SHARE_READ | SHARE_WRITE
>  * The creation mode defaults to OPEN_EXISTING
>  * The flags default to NORMAL
>  * 
>  * To open a directory, pass File::BACKUP_SEMANTICS as the 'flags'
> argument.
> 
> So, with this I can do:
> 
> dir = "C:\\TEST" # directory
> fh = File.nopen(dir,nil,nil,nil,File::BACKUP_SEMANTICS)
> p fh # Yup, it's a File object
> p fh.class # File
> fh.close
> 
> I can also open a plain file and read the contents.  So far, so good.
> But, when I try to write to the file, I get an IOError claiming the file
> isn't opened for writing.  Shouldn't the WRITE_DATA flag have given me
> permission to write?  I tried combinations of some other flags with no
> luck.
> 
> Also, I noticed that if I try to use some of the new instance methods
> like this:
> 
> fh = File.nopen("C:\\temp.txt",File::WRITE_ATTRIBUTES)
> fh.hidden = true
> fh.close
> 
> I get "test.rb:16:in `hidden=': cannot convert nil into String
> (TypeError)"
> 
> Any ideas on these?
> 
> Please take a look and also let me know what you think in general of an
> nopen() method.
> 
WARNING: You are gone too far into the ruby core :-)

I think the Ruby developer should implement the win32 open function compatible with unix.
We might take over nopen function to win32 expert ruby developer like NAKAMURA Usaku  <usa at ruby-lang.org> or Nobuyoshi Nakada  <nobu at ruby-lang.org>.

Regards,

Park Heesob



--MIME Multi-part separator--



More information about the win32utils-devel mailing list