Re: path names with spaces
Re: path names with spaces
- Subject: Re: path names with spaces
- From: "Clark S. Cox III" <email@hidden>
- Date: Thu, 17 Jan 2002 08:55:30 -0500
On Thursday, January 17, 2002, at 06:08 , Markus Hitter wrote:
Am Donnerstag den, 17. Januar 2002, um 02:01, schrieb Andreas Wolf:
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.
Try to put the name into single or double quotes. Should be easier than
adding backslashes.
Like:
NSString *path;
unsigned char *tempStr;
FILE *myPipe;
...
sprintf(tempStr, "cat \"%s\"", [path cString]);
myPipe = popen(tempStr, "r");
if (myPipe) ...
Instead of [path cString], you should be using [path
fileSystemRepresentation]. If you use cString, and the string contains
characters that can't be represented by the default C-string encoding (i.e.
it contains foreign characters), it will raise an exception.
--
Clark S. Cox, III
email@hidden
http://www.whereismyhead.com/clark/