noreply at rubyforge.org
2010-Aug-25 04:47 UTC
[Win32utils-devel] [ win32utils-Bugs-28499 ] File.dirname should not consider trailing slashes
Bugs item #28499, was opened at 2010-08-24 21:47 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Daniel Berger (djberg96) Assigned to: Nobody (None) Summary: File.dirname should not consider trailing slashes Initial Comment: The PathRemoveFileSpec function says it removes the trailing file name and backslash from a path if present. However, this doesn''t seem to be the case with the wide character functions: require ''win32/file'' irb(main):005:0> File.dirname("//foo/bar/baz") => "\\foo\bar" irb(main):006:0> File.dirname("//foo/bar/baz/") => "\\foo\bar\baz" That is not correct. Regards Dan (me) ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85
noreply at rubyforge.org
2010-Aug-25 05:52 UTC
[Win32utils-devel] [ win32utils-Bugs-28499 ] File.dirname should not consider trailing slashes
Bugs item #28499, was opened at 2010-08-25 13:47 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85 Category: win32-file Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Daniel Berger (djberg96) Assigned to: Nobody (None) Summary: File.dirname should not consider trailing slashes Initial Comment: The PathRemoveFileSpec function says it removes the trailing file name and backslash from a path if present. However, this doesn''t seem to be the case with the wide character functions: require ''win32/file'' irb(main):005:0> File.dirname("//foo/bar/baz") => "\\foo\bar" irb(main):006:0> File.dirname("//foo/bar/baz/") => "\\foo\bar\baz" That is not correct. Regards Dan (me) ---------------------------------------------------------------------->Comment By: Park Heesob (phasis68)Date: 2010-08-25 14:52 Message: Although I understand the behaviour, that is not correct in view of RubyDoc. Here is a simple patch. --- file.rb.org 2010-08-25 14:40:52.846324163 +0900 +++ file.rb 2010-08-25 14:40:52.734575269 +0900 @@ -514,7 +514,7 @@ # def dirname(file) raise TypeError unless file.is_a?(String) - file = multi_to_wide(file) + file = multi_to_wide(file.gsub(/[\/\]+$/,'''')) # Convert slashes to backslashes for the Windows API functions file.tr!(File::SEPARATOR, File::ALT_SEPARATOR) Regards, Park Heesob ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85
noreply at rubyforge.org
2010-Aug-29 15:46 UTC
[Win32utils-devel] [ win32utils-Bugs-28499 ] File.dirname should not consider trailing slashes
Bugs item #28499, was opened at 2010-08-24 21:47 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85 Category: win32-file Group: Code>Status: Closed >Resolution: AcceptedPriority: 3 Submitted By: Daniel Berger (djberg96)>Assigned to: Daniel Berger (djberg96)Summary: File.dirname should not consider trailing slashes Initial Comment: The PathRemoveFileSpec function says it removes the trailing file name and backslash from a path if present. However, this doesn''t seem to be the case with the wide character functions: require ''win32/file'' irb(main):005:0> File.dirname("//foo/bar/baz") => "\\foo\bar" irb(main):006:0> File.dirname("//foo/bar/baz/") => "\\foo\bar\baz" That is not correct. Regards Dan (me) ---------------------------------------------------------------------->Comment By: Daniel Berger (djberg96)Date: 2010-08-29 08:46 Message: Unfortunately that patch caused some other test failures. I ended up using PathRemoveBackslash, combined with a short circuit for empty paths, to solve it. I also added some more tests. Fixed in git, I''ll push out a release tonight. Regards, Dan ---------------------------------------------------------------------- Comment By: Park Heesob (phasis68) Date: 2010-08-24 22:52 Message: Although I understand the behaviour, that is not correct in view of RubyDoc. Here is a simple patch. --- file.rb.org 2010-08-25 14:40:52.846324163 +0900 +++ file.rb 2010-08-25 14:40:52.734575269 +0900 @@ -514,7 +514,7 @@ # def dirname(file) raise TypeError unless file.is_a?(String) - file = multi_to_wide(file) + file = multi_to_wide(file.gsub(/[\/\]+$/,'''')) # Convert slashes to backslashes for the Windows API functions file.tr!(File::SEPARATOR, File::ALT_SEPARATOR) Regards, Park Heesob ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=28499&group_id=85