Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Which path separator

Which path separator
Thread Tools
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Mar 4, 2002, 02:26 PM
 
I have a question I've not seen posted about relative to C. I'm using Codewarrior to port a library (our client uses that system) and there is an issue regarding paths.

Sometimes it seems like when I compile a program using the library it requires the old type of path separators. ( At other times it requires the unix path separator (/).

The problem is that the clients may wish to store explicit paths in their data files. Is there a standard call to know which separator is appropriate? Normally we just do that with a comparison in our code for the platform. But Codewarrior (or is it the Mac itself?) seems a bit inconsistent here. In both test programs I am making Carbon apps. Unfortunately I'm not that familiar with the latest version of Codewarrior (v.7). We just got it to do the port for our client.
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Mar 4, 2002, 02:44 PM
 
I have not been doing any Carbon Developing, so I don't have a cut-and-dried answer to this. But I might be able to lend a clue from my dusty memories on an intro to Carbon I sat through...

The root filesystem separator in MacOS X is '/', but for older classic programs this has to be translated into/out of ":". So every time you see a call from the non-new parts of Carbon I would expect that ':' would dominate, but if you are using the new style of file-descriptors (the ones that allow for really large file (terabytes) and long filenames, then you are looking for '/'.

Hope this helps...
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Mar 4, 2002, 04:27 PM
 
The code, however, makes no explicit Carbon calls. At least not on my end. It simply uses the standard C libraries. (i.e. fopen, etc.) I wrote a demo to test Codewarrior and it required : as the separator. Then my clients sent me a demo they were having trouble with and it required / as the separator.

Clearly there is something going on in the Codewarrior version of the libraries, but I can't imagine what.
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Mar 8, 2002, 01:49 AM
 
You can convert between Mac-style and Unix-style paths using the functions in CFURL.h. It'll handle more than just the path separator, too -- it knows when to convert "Disk:Folder:File" to "/Volumes/Disk/Folder/File" and so forth.

Slash seems to be preferred over colon when representing file paths to the user, though there's no standardized recommendation from Apple. Basically, if you're allowing user-written paths, you'll need to be prepared to accept any of several types, as does the Finder's Go To Folder window.
Rick Roe
icons.cx | weblog
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2