[p4] Windows file name length issues

Jeff Grills jgrills at drivensnow.org
Sun Aug 19 16:16:22 PDT 2007

So if the perforce daemon/service was compiled against the Unicode API on
Win32 (which, I think, would be independent of the server supporting
unicode), then we might be able to use \\?\ in the depot root to get long
files names?  I decided to try this:

c:\Program Files\Perforce>p4d -r \\?\c:\tmp\p4depot
Perforce server error:
        Root directory (set with $P4ROOT or -r flag) invalid.
        chdir: \\p4depot: The filename, directory name, or volume label
syntax is incorrect.

I was hoping that the root would be prefixed onto all the CreateFile calls
for the depot, but since it's failing in a chdir() call, I suspect that all
the file opens would be relative, so adjusting the server root wouldn't do
the trick.  So then I thought I might be able to do it with the depot
mapping.  So I set my depot to \\?\depot/..., and tried to submit a file:

Change 1 created with 1 open file(s).
Submitting change 1.
Locking 1 files ...
add //depot/size.txt#1
Date 2007/08/19 18:13:45:
Operation: dm-SubmitFile
Operation 'mkdir' failed.
Librarian checkin \\?\depot/size.txt failed.
RCS can't make directory for \\?\depot/size.txt,v!
mkdir: \\: The filename, directory name, or volume label syntax is

So that's not going to work either.  I suspect someone could make an API
hooking DLL that would translate every CreateFileA() call to unicode, add
the necessary path stuff, and it would then support long file names.  That
would be a non-trivial amount of work.  That sure seems useful - I would
think that it could be made to make every application support long file

It's probably a lot easier to ask Perforce support to give us a Win32 p4
server with the necessary changes to use \\?\.


-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Patrick Bennett
Sent: Friday, August 17, 2007 10:26 PM
To: David Weintraub
Cc: perforce-user at perforce.com; Robert Cowham; Albrecht, Matt
Subject: Re: [p4] Windows file name length issues

No, the Win32 APIs supports very long filenames (up to 32k), it's just 
that it requires some programmatic contortions that very few programs 
make, so the default 255 limit is still very commonly run into. To use long
filenames, programs have to call the Unicode versions (the 
'W' versions - ie CreateFileW) with \\?\ prepended to the path. These longer
paths have been supported since, I believe, the first 
Windows NT version (3.5 as I vaguelly recall - it was a long time ago).  
Windows 95/98/ME are limited to 255.

Patrick Bennett

More information about the perforce-user mailing list