Skip navigation.
 
mlRe: path names with spaces
FROM : Clark S. Cox III
DATE : Thu Jan 17 14:55:30 2002

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_removed>
http://www.whereismyhead.com/clark/


Related mailsAuthorDate
mlpath names with spaces Andreas Wolf Jan 17, 02:01
mlRe: path names with spaces Ben Jansen Jan 17, 02:32
mlRe: path names with spaces dave sapone Jan 17, 11:53
mlRe: path names with spaces Markus Hitter Jan 17, 12:08
mlRe: path names with spaces Clark S. Cox III Jan 17, 14:55
mlRe: path names with spaces Douglas Davidson Jan 17, 18:34
mlRe: path names with spaces Malte Tancred Jan 17, 19:23
mlRe: path names with spaces Andrew Pinski Jan 17, 19:33
mlRe: path names with spaces Douglas Davidson Jan 17, 19:36
mlRe: path names with spaces Malte Tancred Jan 17, 20:17
mlRe: path names with spaces Markus Hitter Jan 17, 21:31