You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Colin JN Breame <co...@breame.com> on 2004/10/27 19:52:41 UTC

Long path names in windows

In the windows version of svn, there is a difference between:

$ svn co svn://repos c:\path

and

$ svn co svn://repos path

The first being an absolute path and the second being relative.

The difference seems to be with long path names.  I have read somewhere 
that relative paths have a max length of 255 whereas absolute paths can 
be much, much longer.

So, I suggest that all relative paths are converted to their absolute 
versions when running on windows.  Infact, maybe there is a function in 
the apr that can be used.  Anyone know about this?

Colin


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by Julian Foad <ju...@btopenworld.com>.
C. Michael Pilato wrote:
> I've been mildly pushing for Subversion use absolute paths internally
> forEVER.  Good luck in your effort.  :-)

It has occurred to me that absolute paths would in some ways be easier to 
handle, but I have not really noticed anyone else saying so.  Perhaps you could 
write down your thoughts on this, and create a "Task" issue in the issue 
tracker?  It is not obvious at first thought what the pros and cons of doing so 
might be, and there would be difficulties - like how to keep command output 
brief when the input is brief.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by "C. Michael Pilato" <cm...@collab.net>.
Colin JN Breame <co...@breame.com> writes:

> So, I suggest that all relative paths are converted to their absolute
> versions when running on windows.  Infact, maybe there is a function
> in the apr that can be used.  Anyone know about this?

I've been mildly pushing for Subversion use absolute paths internally
forEVER.  Good luck in your effort.  :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by "C. Michael Pilato" <cm...@collab.net>.
Colin JN Breame <co...@breame.com> writes:

> Looks like absolute and unc paths have \\?\ and \\?\UNC appended.
> This function is called from all the correct places (apr_file_open,
> etc.)

Yep.  APR is doing the right thing throughout, as far as my previous
research could show.

> I see two solutions to the problem:
> 
> a) use absolute paths in subversion
> b) change the above code so that
>     - relative paths that are longer than MAX_PATH are special cased
>     - these paths are converted into absolute paths then have \\?\ prepended
> 
> I would be willing to prepare a patch for (b).  What do you think?

I think a guy that shows up with a patch is at least twice as loud as
those who don't (myself included).  :-)  I'm not fond of adding more
OS-specific code to Subversion, but if you can find a way to
minimalize the reaches of that, it could be worth it.  

Also, (b) is likely the less hurtful solution.  On Windows systems <
Win2k, switching to absolute paths all over would probably just
exacerbate the problem of long paths, since those system have a
255-ish limit on *all* path, relative or absolute.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by Colin JN Breame <co...@breame.com>.
C. Michael Pilato wrote:

>Stefano Spinucci <vi...@yahoo.it> writes:
>
>I've done recent searches around this too, and I'm afraid your
>information is incomplete.  If you use the Unicode versions of the
>path-related functions we're discussing (CreateFile and friends), and
>are on a Win2k or better version of the OS, you can get a 32k path:
>
>   In the ANSI version of this function, the name is limited to
>   MAX_PATH characters. To extend this limit to 32,767 wide
>   characters, call the Unicode version of the function and prepend
>   "\\?\" to the path. For more information, see Naming a File[1]
>
>[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/naming_a_file.asp
>
>  
>
apr/file_io/win32/open.c: utf8_to_unicode_path

if (srcremains > MAX_PATH) {
        if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) {
            wcscpy (retstr, L"\\\\?\\");
            retlen -= 4;
            t += 4;
        }
        else if ((srcstr[0] == '/' || srcstr[0] == '\\')
              && (srcstr[1] == '/' || srcstr[1] == '\\')
              && (srcstr[2] != '?')) {
            /* Skip the slashes */
            srcstr += 2;
            srcremains -= 2;
            wcscpy (retstr, L"\\\\?\\UNC\\");
            retlen -= 8;
            t += 8;
        }
    }

Looks like absolute and unc paths have \\?\ and \\?\UNC appended.  This 
function is called from all the correct places (apr_file_open, etc.)

I see two solutions to the problem:

a) use absolute paths in subversion
b) change the above code so that
    - relative paths that are longer than MAX_PATH are special cased
    - these paths are converted into absolute paths then have \\?\ prepended

I would be willing to prepare a patch for (b).  What do you think?



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by "C. Michael Pilato" <cm...@collab.net>.
Stefano Spinucci <vi...@yahoo.it> writes:

> Searching in microsoft site, I guess I found some text
> confirming the path limit to 260 chars (without
> difference from absolute or relative).

I've done recent searches around this too, and I'm afraid your
information is incomplete.  If you use the Unicode versions of the
path-related functions we're discussing (CreateFile and friends), and
are on a Win2k or better version of the OS, you can get a 32k path:

   In the ANSI version of this function, the name is limited to
   MAX_PATH characters. To extend this limit to 32,767 wide
   characters, call the Unicode version of the function and prepend
   "\\?\" to the path. For more information, see Naming a File[1]

[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/naming_a_file.asp

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by Stefano Spinucci <vi...@yahoo.it>.
Searching in microsoft site, I guess I found some text
confirming the path limit to 260 chars (without
difference from absolute or relative).


From
http://www.microsoft.com/winlogo/software/swglossary.mspx
I read:

long file name: ...Windows XP allows file names that
are up to MAX_FILE characters long....

long path name: ...Windows XP allows paths that are up
to MAX_PATH characters long...

MAX_FILE: ...The current value assigned to MAX_FILE is
255.

MAX_PATH: ...The current value assigned to MAX_PATH is
260.


Furthermore, in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiopathclassgetfullpathtopic.asp
(and this apply to the entire .net framework
specification) I found:

PathTooLongException: ...on Windows-based platforms,
paths must be less than 248 characters, and file names
must be less than 260 characters.


---
Stefano Spinucci
Italy



--- Colin JN Breame <co...@breame.com> wrote:

> Julian Foad wrote:
> 
> > Colin JN Breame wrote:
> >
> >> The difference seems to be with long path names. 
> I have read 
> >> somewhere that relative paths have a max length
> of 255 whereas 
> >> absolute paths can be much, much longer.
> >
> >
> > Where does this limit apply?  In the inputs and
> outputs of certain API 
> > functions?  Ones that we use?
> 
> This limit applies on my Windows XP box.  AFAIK,
> this limit is actually 
> in the win32 api, where relative paths are limited
> to 255 but absolute 
> paths are not. e.g. opening a file
> 
> >
> >> So, I suggest that all relative paths are
> converted to their absolute 
> >> versions when running on windows.  Infact, maybe
> there is a function 
> >> in the apr that can be used.  Anyone know about
> this?
> >
> >
> > It is hard to evaluate this solution because it is
> not clear what 
> > problem you are trying to solve - presumably some
> problem with paths 
> > being too long, but what exactly?  Is this an
> actual problem that can 
> > be demonstrated?  Please show us how.
> 
> I have a Real Life(tm) repository that has very long
> path names.
> 
> To demostrate, in Windows:
> 1) create a directory structure that is very deep.
> e.g. more than 255 
> characters.  One way of doing this is using cygwin
> (while true; do mkdir 
> test; cd test; done).  As cygwin suffers from the
> same problem, it will 
> stop when the 255 char limit is exceeded.
> 
> 2) Create a file (echo "hello" > afile) in the
> deepest directory.
> 
> 3) Then import into a repository.
> 
> 4) Check out the repository into a new directory
> called 'path'.  Notice 
> the difference between the two checkouts:
> 
>      a) svn co svn://repos c:\path
> and
> (from the parent directory of path)
>      b) svn co svn://repos path
> 
> (a) should succeed and (b) should fail, assuming
> that the instructions 
> are correct.
> 
> >
> > - Julian
> >
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail:
> dev-help@subversion.tigris.org
> 
> 



	
		
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by Colin JN Breame <co...@breame.com>.
Julian Foad wrote:

> Colin JN Breame wrote:
>
>> The difference seems to be with long path names.  I have read 
>> somewhere that relative paths have a max length of 255 whereas 
>> absolute paths can be much, much longer.
>
>
> Where does this limit apply?  In the inputs and outputs of certain API 
> functions?  Ones that we use?

This limit applies on my Windows XP box.  AFAIK, this limit is actually 
in the win32 api, where relative paths are limited to 255 but absolute 
paths are not. e.g. opening a file

>
>> So, I suggest that all relative paths are converted to their absolute 
>> versions when running on windows.  Infact, maybe there is a function 
>> in the apr that can be used.  Anyone know about this?
>
>
> It is hard to evaluate this solution because it is not clear what 
> problem you are trying to solve - presumably some problem with paths 
> being too long, but what exactly?  Is this an actual problem that can 
> be demonstrated?  Please show us how.

I have a Real Life(tm) repository that has very long path names.

To demostrate, in Windows:
1) create a directory structure that is very deep. e.g. more than 255 
characters.  One way of doing this is using cygwin (while true; do mkdir 
test; cd test; done).  As cygwin suffers from the same problem, it will 
stop when the 255 char limit is exceeded.

2) Create a file (echo "hello" > afile) in the deepest directory.

3) Then import into a repository.

4) Check out the repository into a new directory called 'path'.  Notice 
the difference between the two checkouts:

     a) svn co svn://repos c:\path
and
(from the parent directory of path)
     b) svn co svn://repos path

(a) should succeed and (b) should fail, assuming that the instructions 
are correct.

>
> - Julian
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Long path names in windows

Posted by Julian Foad <ju...@btopenworld.com>.
Colin JN Breame wrote:
> The difference seems to be with long path names.  I have read somewhere 
> that relative paths have a max length of 255 whereas absolute paths can 
> be much, much longer.

Where does this limit apply?  In the inputs and outputs of certain API 
functions?  Ones that we use?

> So, I suggest that all relative paths are converted to their absolute 
> versions when running on windows.  Infact, maybe there is a function in 
> the apr that can be used.  Anyone know about this?

It is hard to evaluate this solution because it is not clear what problem you 
are trying to solve - presumably some problem with paths being too long, but 
what exactly?  Is this an actual problem that can be demonstrated?  Please show 
us how.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org