Re: How to deal with long pathnames in Cocoa ?
Re: How to deal with long pathnames in Cocoa ?
- Subject: Re: How to deal with long pathnames in Cocoa ?
- From: "Clark S. Cox III" <email@hidden>
- Date: Wed, 16 Jan 2002 12:52:14 -0500
Cross-posted to Darwin-Dev.
On Wednesday, January 16, 2002, at 10:22 , Stiphane Sudre wrote:
On Wednesday, January 16, 2002, at 04:17 PM, Lance Bland wrote:
On Wednesday, January 16, 2002, at 09:57 AM, Ondra Cada wrote:
I've just tried that in my NeXTStep
3.3, and succeeded to kill Edit the very same way -- by trying to save
a file
into path longer than 1024 characters).
Do please file a bugreport.
Look at the file /usr/include/sys/syslimits.h
and this line:
#define PATH_MAX 1024 /* max bytes in pathname */
and you will understand.
This limit is known by everyone I think. The issue is more how are we
supposed to deal with it when it's possible to have pathname bigger than
PATH_MAX and calling [NSFileManager defaultManager] fileExistAtPath (or
another one) would not be working.
One solution could be to use - changeCurrentDirectoryPath: to avoid the
1024 limits and use relative path names everywhere. But this does not
look like a realistic solution.
I wonder how easy it would be to modify Darwin (and
Cocoa/CoreFoundation) to allow longer than 1024-byte paths. Which is
absurd when you think that the path names are in UTF-8, and each file name
can be up to 255 characters. This means that a single directory at the
root level that had a 255-char long name, consisting of high-unicode
characters would be unrepresentable, because the name itself could take as
much as 1530 bytes to represent.
A much more reasonable limit on pathnames would be 64K instead of 1K.
This would allow, in a worst-case, 42 directory levels.
--
Clark S. Cox, III
email@hidden
http://www.whereismyhead.com/clark/