Feature #3356

Add GetShortPathName to ruby

Added by Christian Höltje almost 4 years ago. Updated over 1 year ago.

[ruby-core:30470]
Status:Feedback
Priority:Low
Assignee:Usaku NAKAMURA
Category:lib
Target version:next minor

Description

=begin
Hi!

I use Ruby on windows and it would be really useful to have access to GetShortPathName in ruby.

I have a monkey-patch to add Pathname.shortpath (attached) to demonstrate it. Probably realpath, etc. should take this in to account as well, since in windows, only the shortpath is canonical.

In addition, the shortpath doesn't need to be escaped, so you can use it with backticks (`), etc.

Ciao!
=end

pathname-shortpath.rb Magnifier - Monkey patch to pathname (640 Bytes) Christian Höltje, 05/28/2010 01:42 AM

History

#1 Updated by Akira Tanaka almost 4 years ago

=begin
2010/5/28 Christian Höltje redmine@ruby-lang.org:

Bug #3356: Add GetShortPathName to ruby
http://redmine.ruby-lang.org/issues/show/3356

I use Ruby on windows and it would be really useful to have access to GetShortPathName in ruby.

I think it should be defined as a class method of File at first,
as other many methods in Pathname.
--
Tanaka Akira

=end

#2 Updated by Roger Pack over 2 years ago

I could use this as well (because some File-like classes return an 8.3 filename, some the full filename, so not always is the 8.3 name available), though ffi is or winapi is a good work-around for the present.

#3 Updated by Yusuke Endoh about 2 years ago

  • Description updated (diff)
  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada

#4 Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Assigned to Feedback
  • Assignee deleted (Nobuyoshi Nakada)
  • Priority changed from Normal to Low

What do you mean by "canonical"?
It doesn't feel like "canonical" at all.

#5 Updated by Yusuke Endoh over 1 year ago

  • Target version set to next minor

#6 Updated by Luis Lavena over 1 year ago

  • Assignee set to Usaku NAKAMURA

Hello,

AFAIK shortnames might not be available on some NTFS volumes, under some circumstances I found is off for performance.

Shortname version of a filename is not canonical, is just one of many representations of a file in the filesystem.

If the intention is use short_name to be able to shell out, why not improve Windows support on ShellWords so it properly escapes the path instead?

We keep improving Ruby on Windows to properly support long names and path with spaces that adding this seems counter productive from my point of view.

I'm assigning to Nakamura-san for decision.

Thank you.

#7 Updated by Usaku NAKAMURA over 1 year ago

Hello,

In message " [ruby-trunk - Feature #3356] Add GetShortPathName to ruby"
on Nov.21,2012 00:17:14, luislavena@gmail.com wrote:

Shortname version of a filename is not canonical, is just one of many representations of a file in the filesystem.

agreed.
I've realized that the shortname is a kind of a hardlink.

If the intention is use short_name to be able to shell out, why not improve Windows support on ShellWords so it properly escapes the path instead?

We keep improving Ruby on Windows to properly support long names and path with spaces that adding this seems counter productive from my point of view.

agreed.

However, improving the longname (expecially including spaces) is not
conflict to add a new method to get shortname, I think.
Since I do not have a usecase of the method, I cannot judge whether
the method is necessery or not.
Therefore, users who need the method should show some suitable usecases.
Of course, as menthioned above, to gloss over the problems in ruby itself
with handling longnames.

Regards,
--
U.Nakamura usa@garbagecollect.jp

Also available in: Atom PDF