[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
Daniel Berger
djberg96 at gmail.com
Tue Jul 29 08:33:50 EDT 2008
Heesob Park wrote:
> Hi,
>
> 2008/7/29 Daniel Berger <djberg96 at gmail.com>:
>> Heesob Park wrote:
>>> Hi,
>>>
>>> 2008/7/28 Daniel Berger <djberg96 at gmail.com>:
>>>> 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?
>>>>
>>> I guess it is related with the Wide and Ansi API function detection
>>> problem.
>>>
>>> After modification of stat.rb
>>> #93 GetFileAttributes to GetFileAttributesA
>>> #558 CreateFile to CreateFileA
>>> works fine for me.
>> Yes, thanks. Also, there was some kind of bug in the multi_to_wide and
>> wide_to_multi helper methods in Windows::Unicode. I've refactored those and
>> updated win32-file-stat to use wide character functions internally. All
>> tests pass now.
>>
>> I'll have to update win32-file next to use the wide character functions. I
>> think there was one other bug (a bad error message somewhere) I need to fix,
>> too.
>>
> That's the same problem.
> If you modify FormatMessage to FormatMessageA (#423 of error.rb),
> It works fine.
I guess all Windows error messages are in English anyway. Unless Vista
changed things. :)
Thanks,
Dan
More information about the win32utils-devel
mailing list