Daniel Berger
2008-Oct-01 20:53 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
Hi, I don''t know when this started happening, but I can''t win32-dir tests to pass any more for the create_junction method. It looks like the junction is created, but it''s not valid. Here''s the results of the tests on Vista using the latest from CVS: Started ....................E.E................................. Finished in 0.477 seconds. 1) Error: test_create_junction_ascii(TC_Win32_Dir): Errno::EINVAL: Invalid argument - test_to_directory ./test/test_dir.rb:38:in `open'' ./test/test_dir.rb:38:in `entries'' ./test/test_dir.rb:38:in `test_create_junction_ascii'' 2) Error: test_create_junction_unicode(TC_Win32_Dir): Errno::EINVAL: Invalid argument - ?????????? ./test/test_dir.rb:44:in `open'' ./test/test_dir.rb:44:in `entries'' ./test/test_dir.rb:44:in `test_create_junction_unicode'' 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications rake aborted! Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib "C:/Ruby/lib/rub...] (See full trace by running task with --trace) Any ideas? Thanks, Dan
Heesob Park
2008-Oct-02 13:58 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
Hi, 2008/10/2 Daniel Berger <djberg96 at gmail.com>:> Hi, > > I don''t know when this started happening, but I can''t win32-dir tests to > pass any more for the create_junction method. > > It looks like the junction is created, but it''s not valid. Here''s the > results of the tests on Vista using the latest from CVS: > > Started > ....................E.E................................. > > Finished in 0.477 seconds. > > 1) Error: > test_create_junction_ascii(TC_Win32_Dir): > Errno::EINVAL: Invalid argument - test_to_directory > ./test/test_dir.rb:38:in `open'' > ./test/test_dir.rb:38:in `entries'' > ./test/test_dir.rb:38:in `test_create_junction_ascii'' > > 2) Error: > test_create_junction_unicode(TC_Win32_Dir): > Errno::EINVAL: Invalid argument - ?????????? > ./test/test_dir.rb:44:in `open'' > ./test/test_dir.rb:44:in `entries'' > ./test/test_dir.rb:44:in `test_create_junction_unicode'' > > 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 > notifications > rake aborted! > Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib > "C:/Ruby/lib/rub...] > > (See full trace by running task with --trace) > > Any ideas? >It is due to the change of multi_to_wide method. Trailing \0''s and wide_string.size mismatch problem. Modify line#111 of dir.rb wide_string = multi_to_wide(buf_target) To wide_string = multi_to_wide(buf_target)[0..-3] works for me in case of ascii junction. In case of the unicode, more work is needed. Regards, Park Heesob
Berger, Daniel
2008-Oct-02 14:11 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Thursday, October 02, 2008 7:59 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction > > Hi, > > 2008/10/2 Daniel Berger <djberg96 at gmail.com>: > > Hi, > > > > I don''t know when this started happening, but I can''t > win32-dir tests > > to pass any more for the create_junction method. > > > > It looks like the junction is created, but it''s not valid. > Here''s the > > results of the tests on Vista using the latest from CVS: > > > > Started > > ....................E.E................................. > > > > Finished in 0.477 seconds. > > > > 1) Error: > > test_create_junction_ascii(TC_Win32_Dir): > > Errno::EINVAL: Invalid argument - test_to_directory > > ./test/test_dir.rb:38:in `open'' > > ./test/test_dir.rb:38:in `entries'' > > ./test/test_dir.rb:38:in `test_create_junction_ascii'' > > > > 2) Error: > > test_create_junction_unicode(TC_Win32_Dir): > > Errno::EINVAL: Invalid argument - ?????????? > > ./test/test_dir.rb:44:in `open'' > > ./test/test_dir.rb:44:in `entries'' > > ./test/test_dir.rb:44:in `test_create_junction_unicode'' > > > > 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 > > omissions, 0 notifications rake aborted! > > Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib > > "C:/Ruby/lib/rub...] > > > > (See full trace by running task with --trace) > > > > Any ideas? > > > It is due to the change of multi_to_wide method. > Trailing \0''s and wide_string.size mismatch problem. > > Modify line#111 of dir.rb > wide_string = multi_to_wide(buf_target) To > wide_string = multi_to_wide(buf_target)[0..-3] works for > me in case of ascii junction.Ah, ok. Thanks. Do you think we should automatically strip the trailing "\000\000" in the multi_to_wide method then? I think this would work because I modified wide_to_multi to automatically append "\000\000" to the incoming string if they weren''t already there.> In case of the unicode, more work is needed.Any suggestions? Regards, 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.
Berger, Daniel
2008-Oct-02 14:15 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Berger, Daniel > Sent: Thursday, October 02, 2008 8:12 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction<snip>> Do you think we should automatically strip the trailing > "\000\000" in the multi_to_wide method then? I think this > would work because I modified wide_to_multi to automatically > append "\000\000" to the incoming string if they weren''t > already there.On second thought, I think that might cause wide character functions to fail. Regards, 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.
Heesob Park
2008-Oct-02 14:25 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
2008/10/2 Berger, Daniel <Daniel.Berger at qwest.com>:>> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Berger, Daniel >> Sent: Thursday, October 02, 2008 8:12 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Problems with win32-dir and >> create_junction > > <snip> > >> Do you think we should automatically strip the trailing >> "\000\000" in the multi_to_wide method then? I think this >> would work because I modified wide_to_multi to automatically >> append "\000\000" to the incoming string if they weren''t >> already there. > > On second thought, I think that might cause wide character functions to > fail. >I think it would be better to define new method for getting the wide_string length than to use String#size method. Regards, Park Heesob
Daniel Berger
2008-Oct-02 23:53 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
Heesob Park wrote:> 2008/10/2 Berger, Daniel <Daniel.Berger at qwest.com>: >>> -----Original Message----- >>> From: win32utils-devel-bounces at rubyforge.org >>> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >>> Berger, Daniel >>> Sent: Thursday, October 02, 2008 8:12 AM >>> To: Development and ideas for win32utils projects >>> Subject: Re: [Win32utils-devel] Problems with win32-dir and >>> create_junction >> <snip> >> >>> Do you think we should automatically strip the trailing >>> "\000\000" in the multi_to_wide method then? I think this >>> would work because I modified wide_to_multi to automatically >>> append "\000\000" to the incoming string if they weren''t >>> already there. >> On second thought, I think that might cause wide character functions to >> fail. >> > I think it would be better to define new method for getting the > wide_string length > than to use String#size method.I have a very alpha "UString" class I''ve got in CVS (in the "shards" project, not win32utils) where I''ve been tinkering with a Windows-only subclass of String. It redefines methods like length, size, etc. I''ve pasted what I''ve done so far below. Or do you think that''s overkill? Regards, Dan # ustring.rb - ALPHA class UString < String include Windows::Unicode include Windows::MSVCRT::String VERSION = ''0.1.0'' ACP = CP_ACP UTF7 = CP_UTF7 UTF8 = CP_UTF8 attr_accessor :encoding alias :at :[] def initialize(string, encoding = UTF8) ustring = multi_to_wide(string, encoding) @encoding = encoding super(ustring) end def inspect wide_to_multi(self, @encoding) end def to_s wide_to_multi(self, @encoding) end def to_str wide_to_multi(self, @encoding) end # Length in chars def length wcslen(self) end # Size in bytes def size strlen(wide_to_multi(self, @encoding)) end # Returns the character (not the numeric value) def [](n) wide_to_multi(self, @encoding).at(n, 1) end end
Berger, Daniel
2008-Oct-15 21:48 UTC
[Win32utils-devel] Problems with win32-dir and create_junction
Hi,> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Thursday, October 02, 2008 8:25 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction > > 2008/10/2 Berger, Daniel <Daniel.Berger at qwest.com>: > >> -----Original Message----- > >> From: win32utils-devel-bounces at rubyforge.org > >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf > Of Berger, > >> Daniel > >> Sent: Thursday, October 02, 2008 8:12 AM > >> To: Development and ideas for win32utils projects > >> Subject: Re: [Win32utils-devel] Problems with win32-dir and > >> create_junction > > > > <snip> > > > >> Do you think we should automatically strip the trailing > "\000\000" in > >> the multi_to_wide method then? I think this would work because I > >> modified wide_to_multi to automatically append "\000\000" to the > >> incoming string if they weren''t already there. > > > > On second thought, I think that might cause wide character > functions > > to fail. > > > I think it would be better to define new method for getting > the wide_string length than to use String#size method.Here''s a minimal WideString class: require ''windows/unicode'' require ''windows/msvcrt/string'' class WideString < String include Windows::Unicode include Windows::MSVCRT::String ACP = CP_ACP UTF7 = CP_UTF7 UTF8 = CP_UTF8 attr_accessor :encoding def initialize(string, encoding = UTF8) super(multi_to_wide(string, encoding)) @encoding = encoding end def length wcslen(self) * 2 end alias size length end Another approach is to monkey-patch String: require ''windows/msvcrt/string'' class String include Windows::MSVCRT::String def wlength wcslen(self) * 2 end alias wsize wlength end What do you think? Regards, 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.