[Win32utils-devel] Rails, WEBrick, win32-file-stat issue

Daniel Berger djberg96 at gmail.com
Sun Jul 27 18:02:30 EDT 2008


Hi all,

Please take a look at RubyForge bug #21272:

http://rubyforge.org/tracker/index.php?func=detail&aid=21272&group_id=85&atid=411

The easiest way to see this for yourself is to create a skeleton Rails 
app, add 'win32/file' to the config/environment.rb file, run "ruby 
script/server", and point your browser at http://localhost:3000.

I've tried refactoring the get_file_type method in stat.rb like so:

def get_file_type(file)
    begin
       handle = CreateFile(
          file,
          GENERIC_READ,
          FILE_SHARE_READ,
          nil,
          OPEN_EXISTING,
          FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories
          nil
       )

       error_num = GetLastError()

       # Ignore errors caused by open/empty/used block devices. We raise
       # a SystemCallError explicitly here in order to maintain
       # compatibility with the FileUtils module.
       if handle == INVALID_HANDLE_VALUE
          unless error_num == ERROR_NOT_READY
             raise SystemCallError, get_last_error(error_num)
          end
       end

       file_type = GetFileType(handle)
       error_num = GetLastError()

       if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR
          raise SystemCallError, get_last_error(error_num)
       end
    ensure
       CloseHandle(handle)
    end
end

But, that's still not fixing it. I've also tried wrapping it in a 
RUBY_CRITICAL block as well as an explicit wide version of CreateFile, 
along with a few different access flags, but I haven't had any luck yet 
so far.

Any ideas?

Thanks,

Dan


More information about the win32utils-devel mailing list