Re: Using pathnames with special characters
Re: Using pathnames with special characters
- Subject: Re: Using pathnames with special characters
- From: Peter Sichel <email@hidden>
- Date: Wed, 1 May 2002 08:49:31 -0400
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.