Daniel Berger
2008-Jul-27 22:02 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
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
Heesob Park
2008-Jul-28 02:50 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
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. Regards, Park Heesob
Daniel Berger
2008-Jul-29 01:08 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
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. Regards, Dan
Heesob Park
2008-Jul-29 01:17 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
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. Regards, Park Heesob
Daniel Berger
2008-Jul-29 12:33 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
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
Park Heesob
2008-Jul-29 13:02 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
----- Original Message ----- From: "Daniel Berger" <djberg96 at gmail.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Tuesday, July 29, 2008 9:33 PM Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue> 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. :) >I guess you are correct only in the English version. In my Windows XP, the error messages are in Korean. :) Regards, Park Heesob
Berger, Daniel
2008-Jul-29 13:57 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Tuesday, July 29, 2008 7:02 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue<snip>> >>> > >> 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. :) > > > I guess you are correct only in the English version. > In my Windows XP, the error messages are in Korean. :)Oh? I didn''t know that. FormatMessageA won''t work for you then, will it? I changed get_last_error not too long ago so that I thought it would work either with -Ku or not. If you have a suggested refactoring, I''m listening. :) Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Park Heesob
2008-Jul-29 14:53 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
----- Original Message ----- From: "Berger, Daniel" <Daniel.Berger at qwest.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Tuesday, July 29, 2008 10:57 PM Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue>> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Tuesday, July 29, 2008 7:02 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > > <snip> > >> >>> >> >> 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. :) >> > >> I guess you are correct only in the English version. >> In my Windows XP, the error messages are in Korean. :) > > Oh? I didn''t know that. > > FormatMessageA won''t work for you then, will it? I changed > get_last_error not too long ago so that I thought it would work either > with -Ku or not. If you have a suggested refactoring, I''m listening. :) >As I mentioned before, FormatMessageA works for me. It returns the ansi character set (euckr aka ksc5601). I guess FormatMessageA should work for all languages. Regards, Park Heesob
Daniel Berger
2008-Jul-30 13:46 UTC
[Win32utils-devel] Rails, WEBrick, win32-file-stat issue
Park Heesob wrote:> ----- Original Message ----- > From: "Berger, Daniel" <Daniel.Berger at qwest.com> > To: "Development and ideas for win32utils projects" > <win32utils-devel at rubyforge.org> > Sent: Tuesday, July 29, 2008 10:57 PM > Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue > > >>> -----Original Message----- >>> From: win32utils-devel-bounces at rubyforge.org >>> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >>> Park Heesob >>> Sent: Tuesday, July 29, 2008 7:02 AM >>> To: Development and ideas for win32utils projects >>> Subject: Re: [Win32utils-devel] Rails, WEBrick, win32-file-stat issue >> <snip> >> >>>>> 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. :) >>>> >>> I guess you are correct only in the English version. >>> In my Windows XP, the error messages are in Korean. :) >> Oh? I didn''t know that. >> >> FormatMessageA won''t work for you then, will it? I changed >> get_last_error not too long ago so that I thought it would work either >> with -Ku or not. If you have a suggested refactoring, I''m listening. :) >> > As I mentioned before, FormatMessageA works for me. > It returns the ansi character set (euckr aka ksc5601). > I guess FormatMessageA should work for all languages.Ok, I changed it to FormatMessageA, and released that change as part of windows-pr 0.9.1. Also, I released win32-file-stat 1.2.8 with the wide character support last night. Thanks! Dan