• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to deal with long pathnames in Cocoa ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to deal with long pathnames in Cocoa ?


  • Subject: How to deal with long pathnames in Cocoa ?
  • From: Stéphane Sudre <email@hidden>
  • Date: Wed, 16 Jan 2002 15:26:42 +0100

The problem:
------------

I was playing with the OutlineView sample code when I had the stupid idea to see how it deals with file's path longer than the 1024 limit.

So I added a succession of folders with a stupid lengthy name in the Finder:

"Once upon a time + 100 characters at least"

I found myself with 14 folders with this name, so a path could be:

/Users/Shared/Once upon a time.../Once upon a time.../Once upon a time.../Once upon a time...

I then run the OutlineView sample code and surprise, surprise, the 4th folder named "Once upon a time + 100 characters at least" was seen as a file not a folder. So it seems there is an issue with some of the NSFileManager calls.

I then tried to use the Open Panel in PB to look at my file hierarchy. Browsing through the 14 folders is working well.
Yet, I had another stupid idea, I clicked on Cancel. This causes PB to crash.

Another stupid idea made me make the test with:
- Preview: Open, go to the Fourteenth folder, click cancel => Preview crash
- TextEdit: same problem.
- Console.app: as soon as I reached the 4th or 5th folder => Crash.
- To sum up every Cocoa Application can crash.

The crash.log being:

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
#0 0x70162b70 in CFGetAllocator
#1 0x7017da38 in CFURLCopyFileSystemPath
#2 0x70c58b84 in FSRefToPath
#3 0x70c8aed4 in -[NSHFSContainer path]
#4 0x70d663e0 in -[NSSavePanel _pathTo:]
#5 0x70d68b5c in -[NSSavePanel cancel:]

Apparent conclusion: The NSFileManager API is not long pathname savvy. The NSURL/CFURL APIs -used by the OpenPanel to do something maybe related to Open Recent- does not seem to.

Since the Cocoa File APIs are pathname based, it's a bit problematic even if I agree the 1024 limits is not often going to be reached.

Question:
---------

Are the HFS+ CarbonCore APIs the only safe solution to go?


  • Follow-Ups:
    • Re: How to deal with long pathnames in Cocoa ?
      • From: Chris Parker <email@hidden>
    • Re: How to deal with long pathnames in Cocoa ?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: NSView
  • Next by Date: Detecting changes in Windows and Controls
  • Previous by thread: HTMLEdit (was: NSView)
  • Next by thread: Re: How to deal with long pathnames in Cocoa ?
  • Index(es):
    • Date
    • Thread