Project

General

Profile

Bug #10819

can't glob win32 short pathname

Added by arton (Akio Tajima) about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x64-mswin64_100]
[ruby-core:67954]

Description

I used to install ruby under the "c:/program files" and use to apply windows short pathname such as "c:/progra~1" and it worked fine.
However, rubygems on ruby 2.2.0 failed to look up gemspec. After some investigation, I found that ruby 2.2.0 failed to glob with short pathname.

for ex) ruby -e 'p Dir.glob("c:/progra~1/*")' #=> []

Also I found that the inter glob string with shortname+wildcard also failed both Ruby 2.1.0 and 2.2.0.

for ex) ruby -e 'p Dir.glob("C:/progra~*/*")' #=> []

The testcase is below.

assert_equal Dir.glob('C:/Program Files*/m*').size, Dir.glob('c:/Progra~*/m*').size

Related issues

Related to Ruby master - Bug #11206: short file name match incompatibilityClosednobu (Nobuyoshi Nakada)Actions

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Description updated (diff)

Akio Tajima wrote:

Also I found that the inter glob string with shortname+wildcard also failed both Ruby 2.1.0 and 2.2.0.

for ex) ruby -e 'p Dir.glob("C:/progra~*/*")' #=> []

It has never been possible.

The testcase is below.

assert_equal Dir.glob('C:/Program Files*/m*').size, Dir.glob('c:/Progra~*/m*').size

There is also ProgramData directory which begins with "Progra".
So the chance it matches is very low, I guess, even if Dir.glob were expand the wildcard.

#2

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r49478.


dir.c: glob legacy short name

  • dir.c (glob_helper): obtain real name with FindFirstFile API instead of matchin all entries, on Windows. [ruby-core:67954] [Bug #10819]

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Anyway, it's dangerous to assume that "progra~1" is always "Program Files".

Updated by arton (Akio Tajima) about 5 years ago

Hi Nob

Anyway, it's dangerous to assume that "progra~1" is always "Program Files".

Thank you. However I use https://github.com/arton/rubygadgets/blob/master/winpath/winpath.rb for this purpose. No problem.

Updated by usa (Usaku NAKAMURA) about 5 years ago

  1. We should not assume that short filenames always contains ~.
    MSDN says that some file systems do not use ~ for short filenames.
    (But I don't know such file systems.)
    See Remarks section of https://msdn.microsoft.com/en-us/library/windows/desktop/aa364980%28v=vs.85%29.aspx .

  2. FindFirstFile API handles short filenames with wildcards.
    Simply we can test it by dir C:\PROGRA~*.

These are only for your information.
I'm not claiming that ruby needs complete support of short filenames.

Updated by usa (Usaku NAKAMURA) about 5 years ago

Usaku NAKAMURA wrote:

  1. We should not assume that short filenames always contains ~. MSDN says that some file systems do not use ~ for short filenames. (But I don't know such file systems.)

Kosaki-san tell me that ISO 9660 filesystem with Joliet extension (in other word, CD-ROM) is such one.

Updated by naruse (Yui NARUSE) about 5 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

ruby_2_2 r49656 merged revision(s) 49478,49536,49533,49537.

#8

Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Related to Bug #11206: short file name match incompatibility added

Also available in: Atom PDF