Re: Using pathnames with special characters
Re: Using pathnames with special characters
- Subject: Re: Using pathnames with special characters
- From: email@hidden
- Date: Wed, 1 May 2002 14:10:12 +0100
The other way to get spaces into your file names is to preceed them by a
back slash
thus "user chosen filepath" becomes "user\ chosen\ filepath" you could
parse the string and insert the backslashes if youu dont want to alter your
code too much
Peter Sichel <email@hidden>@lists.apple.com on 01/05/2002 01:49:31
PM
Sent by: email@hidden
To: Cedric John <email@hidden>, email@hidden
cc:
Subject: Re: Using pathnames with special characters
Which part of Darwin is not cooperating?
From the terminal, you can enclose path names in quotes to include spaces.
I've had no trouble using path names with NSTask and
"authorizationExecuteWithPrivileges". Notice path NSStrings
should be encoded as UTF8 for use in argv CStrings to accommodate
special characters. For example:
count = [filePaths count];
for (i=0; i<count; i++) {
data = [NSMutableData dataWithCapacity:255];
[data set
Data:[[filePaths objectAtIndex:i]
dataUsingEncoding:NSUTF8StringEncoding]];
[data increaseLengthBy:1]; // make null terminated string
args[i] = [data mutableBytes];
}
I probably didn't even need to use a MutableData object and
add a null byte, but I wasn't sure -[NSString dataUsingEncoding:]
would always be followed by a null byte.
Kind Regards,
- Peter
At 11:05 AM +0200 5/1/02, Cedric John wrote:
>
Hi!
>
>
I'm implementing a freeware that needs to send tasks to the OS using
>
pathnames as arguments. However, on difficulty
>
that I encounter is that Darwin will not recognize a pathname on the
>
form "/folder/another folder/ some file name.whatever" since it
>
contains special characters (blanks). Since my freeware requires
>
users to choose their own files, I would need to make the system
>
understand each and every possible pathname. The browser has no
>
problem dealing with them, and I am sure it is a trivial issue, but
>
I am stuck. Does anyone have a clue?
>
>
Thanks a lot in advance!
>
>
Cidric John
>
Ph.D. Student
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************************
Our network may monitor outgoing and incoming e-mail messages for
security and customer service purposes, but this e-mail is confidential.
Please notify the sender immediately if you receive it in error, and then delete it.
Thank you.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.