 |
 |
Which path separator
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |