Project

General

Profile

Bug #10819

can't glob win32 short pathname

Added by arton (Akio Tajima) almost 3 years ago. Updated almost 3 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 trunk - Bug #11206: short file name match incompatibilityClosed

Associated revisions

Revision 49478
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: glob legacy short name

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

Revision 49478
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: glob legacy short name

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

Revision 49478
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: glob legacy short name

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

Revision 49537
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: long path name on Windows

  • dir.c (has_magic): always get long path name on Windows even if no tilde is there. [Bug #10819]
  • dir.c (replace_real_basename): FindFirstFile ignore redirection character, check if exists before call it. cf. [Bug #8597]

Revision 49537
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: long path name on Windows

  • dir.c (has_magic): always get long path name on Windows even if no tilde is there. [Bug #10819]
  • dir.c (replace_real_basename): FindFirstFile ignore redirection character, check if exists before call it. cf. [Bug #8597]

Revision 49537
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

dir.c: long path name on Windows

  • dir.c (has_magic): always get long path name on Windows even if no tilde is there. [Bug #10819]
  • dir.c (replace_real_basename): FindFirstFile ignore redirection character, check if exists before call it. cf. [Bug #8597]

Revision 49656
Added by naruse (Yui NARUSE) almost 3 years ago

merge revision(s) 49478,49536,49533,49537: [Backport #10819]

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

* dir.c (has_magic): always get long path name on Windows even if
  no tilde is there.   [Bug #10819]

* dir.c (replace_real_basename): FindFirstFile ignore redirection
  character, check if exists before call it.  cf. [Bug #8597]

Revision 49892
Added by nobu (Nobuyoshi Nakada) over 2 years ago

dir.c: glob short names

  • dir.c (glob_helper): match patterns against legacy short names too, not only ordinary names. [Bug #10819]
  • win32/dir.h (struct direct): add short name members.
  • win32/win32.c (opendir_internal, readdir_internal): ditto.

Revision 49892
Added by nobu (Nobuyoshi Nakada) over 2 years ago

dir.c: glob short names

  • dir.c (glob_helper): match patterns against legacy short names too, not only ordinary names. [Bug #10819]
  • win32/dir.h (struct direct): add short name members.
  • win32/win32.c (opendir_internal, readdir_internal): ditto.

Revision 49892
Added by nobu (Nobuyoshi Nakada) over 2 years ago

dir.c: glob short names

  • dir.c (glob_helper): match patterns against legacy short names too, not only ordinary names. [Bug #10819]
  • win32/dir.h (struct direct): add short name members.
  • win32/win32.c (opendir_internal, readdir_internal): ditto.

History

#1 [ruby-core:67964] Updated by nobu (Nobuyoshi Nakada) almost 3 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) almost 3 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. [Bug #10819]

#3 [ruby-core:67968] Updated by nobu (Nobuyoshi Nakada) almost 3 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".

#4 [ruby-core:67981] Updated by arton (Akio Tajima) almost 3 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.

#5 [ruby-core:68011] Updated by usa (Usaku NAKAMURA) almost 3 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.

#6 [ruby-core:68012] Updated by usa (Usaku NAKAMURA) almost 3 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.

#7 [ruby-core:68196] Updated by naruse (Yui NARUSE) almost 3 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 2 years ago

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

Also available in: Atom PDF