Bug #10819
closedcan't glob win32 short pathname
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
Updated by nobu (Nobuyoshi Nakada) almost 10 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.
Updated by nobu (Nobuyoshi Nakada) almost 10 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) almost 10 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) almost 10 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) almost 10 years ago
-
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 . -
FindFirstFile API handles short filenames with wildcards.
Simply we can test it bydir 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) almost 10 years ago
Usaku NAKAMURA wrote:
- 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) almost 10 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.
Updated by usa (Usaku NAKAMURA) over 9 years ago
- Related to Bug #11206: short file name match incompatibility added