Rename files containing a slash
Rename files containing a slash
- Subject: Rename files containing a slash
- From: Lorenzo Puleo <email@hidden>
- Date: Mon, 21 Oct 2002 20:19:18 +0200
Hi,
I'm trying to rename a file using a new filename containing a slash.
Since I can't find a Cocoa API that renames files I use the Carbon API:
err = FSRenameUnicode(&destRef, nameLength, name, theInfo.textEncodingHint,
nil);
Each time the fileName proposed contains a slash (that Finder accepts) this
API returns an error. Please may someone help me to fix the trouble?
Thank you.
--
Lorenzo Puleo
mailto:email@hidden
- (BOOL)RenameItem:(NSString*)dest sourceItem:(NSString*)source
{
OSErr err;
UniChar name[256];
UniCharCount nameLength;
FSRef sourceRef, destRef;
FSCatalogInfo theInfo;
NSString *newName = [source lastPathComponent];
// Righ now the variable source seem to contain a ":"
// instead of the slash
NSLog(@"Rename With Source %@", source);
nameLength = [newName length];
[newName getCharacters:name];
err = FSPathMakeRef([source fileSystemRepresentation], &sourceRef,
NULL);
if(err) return NO;
err = FSGetCatalogInfo(&sourceRef, kFSCatInfoTextEncoding, &theInfo,
nil, nil, nil);
if(err) return NO;
err = FSPathMakeRef([dest fileSystemRepresentation], &destRef, NULL);
if(err) return NO;
err = FSRenameUnicode(&destRef, nameLength, name,
theInfo.textEncodingHint, nil);// //kTextEncodingUnknown
if(err) return NO;
return YES;
}
_______________________________________________
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.