[Issue 8967] New: dirEntries throws when encountering a "long path" on windows

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 6 09:56:12 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8967

           Summary: dirEntries throws when encountering a "long path" on
                    windows
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: regan at netmail.co.nz


--- Comment #0 from Regan Heath <regan at netmail.co.nz> 2012-11-06 09:56:10 PST ---
Exception thrown:

Bypasses std.file.FileException at std\file.d(2434)
=== Bypassed ===
std.file.FileException at std\file.d(2434):
E:\basic\2012-10-16_0\abcdefghi1abcdefghi2abcdefghi3abcdefghi4abcdefghi5abcdefghi6abcdefghi7abcdefghi8abcdefghi9abcdefg
hi0\abcdefghi1abcdefghi2abcdefghi3abcdefghi4abcdefghi5abcdefghi6abcdefghi7abcdefghi8abcdefghi9abcdefghi0\abcdefghi1abcdefghi2abcdefghi3abcdefghi4abcdefghi5abcde
fghi6abcdefghi7abcdefghi8abcdefghi9abcdefghi0: The system cannot find the path
specified.

The solution is simple/trivial.  FindFirstFileW will handle "long paths" in the
following format:

  \\?\<path>

where <path> may be C:\folder\... or \\host\share\...

So, the simplest fix is to alter DirIteratorImpl.stepIn, line:
  string search_pattern = buildPath(directory, "*.*");
to read:
  string search_pattern = r"\\?\" ~ buildPath(directory, "*.*");

(I have tried/tested this fix and it works for me)

Alternately (better) have buildPath (on windows) detect paths longer than 256
characters and automatically pre-pend \\?\ itself.  

This should work ok as long as W functions are used, but will cause issues when
some A functions, and other windows functions are used as long paths are not
supported throughout.  

But, in those cases a too long short path would error - just in a different
way.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list