Project

General

Profile

Actions

Bug #7822

closed

Dir.mkdir can't handle long Windows Unicode paths (\\?\UNC\)

Added by shyxormz (Patrick Pokatilo) about 11 years ago. Updated almost 10 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.3p362 (2012-12-25) [i386-mingw32]
Backport:
[ruby-core:52098]

Description

Code:
Dir.mkdir "//?/C:/" + "test" * 100

What I expected:
Ruby will create directory //?/C:/testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest, judging from http://msdn.microsoft.com/en-us/library/aa365247.aspx

What happened on the second call:
Errno::ENOENT: No such file or directory - //?/C:/testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
from (irb):6:in `mkdir'


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #7821: FileUtils.mkdir_p fails on Windows Unicode paths (\\?\UNC\) if dir already existsRejectedusa (Usaku NAKAMURA)02/10/2013Actions

Updated by usa (Usaku NAKAMURA) about 11 years ago

  • Subject changed from Dir.mkdir can't handle long Windows Unicode paths (\\?\UNC\) to Dir.mkdir can't handle long Windows Unicode paths (\\?\UNC\)
  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)

Updated by elovelan (Eric Loveland) almost 10 years ago

The linked article mentions that each component (individual folder in the path) can have a maximum of 255 characters.

The following works:

Dir.mkdir "\\\\?\\C:\\#{'t'*255}"
Dir.mkdir "\\\\?\\C:\\#{'t'*255}\\#{'t'*255}"

However, there is a general Ruby file issue related to this: Windows does not allow forward slashes for Win32 File Namespaces (\\?\ paths). Thus these paths cannot be used with any methods that use File::SEPARATOR, such as File.join since File::SEPARATOR is '/' on Windows.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

(1) Windows has the limitation about the length of each directory name.
It's 255 characters.
So, even if with using UNC name, you cannot make such directory, Patrick.

(2) Yes, you are right, Eric.
Only when using "\\?\", Windows does not recognize "/" as the separator
(the document which Patrick mentioned says so.)
So, use "\" as the separator when using "\\?\" for the time being.

Updated by elovelan (Eric Loveland) almost 10 years ago

I would recommend that this bug be closed. However, I have not found any feature requests for better support of "\\?\". Is it worth submitting one or would this be better handled with a gem?

Updated by usa (Usaku NAKAMURA) almost 10 years ago

  • Related to Bug #7821: FileUtils.mkdir_p fails on Windows Unicode paths (\\?\UNC\) if dir already exists added

Updated by usa (Usaku NAKAMURA) almost 10 years ago

  • Status changed from Assigned to Rejected

After all, the user using special form like "\?" should know the meaning and effect,
so ruby doesn't ought to support it.
Of course, if there is a good patch, I my accept it.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0