Issue #3356 has been updated by Sebastian Schuberth.


Usaku NAKAMURA wrote:

>  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.

I'd also like to see a "shortpath" method implemented, but also the opposite "longpath" (like suggested at [1]).

My use-case is that I need de-duplicate a list of Windows paths, i.e. generate a list of unique paths. The list may contain short paths as well as long paths, so a solution would be to first convert all paths to their long form, and then do case-insensitive string matches. Currently, that does not seem possible in Ruby as there's not way to explicitly get a long path for a short path (also see [2]) or vice versa. If we have a "longpath" (or "shortpath) we should also have a "shortpath" (or "longpath") for symmetry.

[1] http://stackoverflow.com/a/8142448/1127485
[2] http://stackoverflow.com/q/34919422/1127485

----------------------------------------
Feature #3356: Add GetShortPathName to ruby
https://bugs.ruby-lang.org/issues/3356#change-56242

* Author: Christian Hltje
* Status: Feedback
* Priority: Normal
* Assignee: Usaku NAKAMURA
----------------------------------------
=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


---Files--------------------------------
pathname-shortpath.rb (640 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>