• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Rename files containing a slash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Rename files containing a slash
      • From: Rosyna <email@hidden>
    • Re: Rename files containing a slash
      • From: Pierre-Olivier Latour <email@hidden>
    • Re: Rename files containing a slash
      • From: Ondra Cada <email@hidden>
    • Re: Rename files containing a slash
      • From: Ondra Cada <email@hidden>
    • Re: Rename files containing a slash
      • From: Howard Oakley <email@hidden>
  • Prev by Date: Similarly -- Getting the Locale's Re: How to get the Time/Date separators?
  • Next by Date: copyPath API: still error
  • Previous by thread: Re: Quick Simple Bundles Questions
  • Next by thread: Re: Rename files containing a slash
  • Index(es):
    • Date
    • Thread