Bug #7822

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

Added by Patrick Pokatilo about 1 year ago. Updated 3 days ago.

[ruby-core:52098]
Status:Rejected
Priority:Normal
Assignee:Usaku NAKAMURA
Category:-
Target version:-
ruby -v:ruby 1.9.3p362 (2012-12-25) [i386-mingw32] Backport:

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

Related to ruby-trunk - Bug #7821: FileUtils.mkdir_p fails on Windows Unicode paths (\\?\UNC... Rejected 02/10/2013

History

#1 Updated by Usaku NAKAMURA about 1 year 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 Usaku NAKAMURA

#2 Updated by Eric Loveland 3 days 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.

#3 Updated by Usaku NAKAMURA 3 days 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.

#4 Updated by Eric Loveland 3 days 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?

#5 Updated by Usaku NAKAMURA 3 days ago

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

#6 Updated by Usaku NAKAMURA 3 days 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.

Also available in: Atom PDF