path names with spaces
path names with spaces
- Subject: path names with spaces
- From: Andreas Wolf <email@hidden>
- Date: Wed, 16 Jan 2002 17:01:53 -0800
Does anybody know how to create a UNIX filesystem representation of
a path that includes whitespaces?
I ran into weird situations when trying to popen() a path that
was retrieved with -(NSString*) pathForResource:ofType because the path
name for that resource contains a space character. The shell that gets
invoked
implicitly interprets the space as a delimiter for the path.
First, -(const char*) fileSystemRepresentation didn't help at all. I
expected that it
would replace the space character by '\ '.
Also, I couldn't just programmatically insert a '\' before the space
because cocoa doesn't seem to handle
that character quite right.
For example:
char n[2];
n[0]=0x5c; // backslash character
n[1]=0x0; // c string delimiter
NSLog([NSString stringWithCString:n];
what I get as output are four backslash characters ("\\\\").
Is there a bug in how cocoa handles the \ character?
Thanks,
-Andreas