ADC Home > Reference Library > Technical Q&As > Graphics & Imaging > ColorSync >

Using cmPathBased profile locations on Mac OS X


Q: I'm using ColorSync routines to create and write profiles. On Mac OS 10.2, if I pass a file name with a '/' character in it to CMNewProfile I get various file system errors that do not occur when this same code is run on earlier versions of Mac OS X (or Mac OS 9 for that matter).

These errors seem to indicate the file name is being interpreted differently, as if the '/' characters are being seen as pathname delimiters instead of part of the file name. What's going on?

A: When using cmPathBased profile locations on Mac OS X, the path must be a full POSIX-based path. If the path works with the fopen function, it should work in ColorSync. This means:

1) The path must start with '/'

2) Directories are delimited with '/'

3) Names that appear to contain a '/' should instead have a ':' in the path

POSIX file names with the ':' character will look different in the Finder and with the Carbon APIs. For example, a POSIX file "/Library/foo:bar" would appear as "<boot drive name>:Library:foo/bar" in the Finder and in the Carbon APIs.

4) Names that contain high-ASCII or Unicode characters should be UTF8-encoded

As an example, if your application prompts the user for a profile name to use when placing a profile in /Library/ColorSync/Profiles/ you should:

1) Get the string from the user

2) Convert from the current encoding to UTF8-encoding

3) Convert '/' characters to ':' and vice-versa

4) Append the string to "/Library/ColorSync/Profiles/"

As to why the behavior changed slightly in Mac OS 10.2:

1) Pre-Mac OS 10.2, ColorSync internally used FSSpec-based file I/O. Path-based locations were internally converted into FSSpecs.

2) For slightly better performance on Mac OS 10.2, ColorSync internally uses POSIX-based file I/O. FSSpec-based locations are internally converted into posix paths.

Most likely the pre-Mac OS 10.2 path-to-spec conversion was a bit too forgiving.

Paths that work on Mac OS 10.2 should work on earlier releases.


[Nov 06 2002]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.