• 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
Re: FSSpec from NSString Problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FSSpec from NSString Problems


  • Subject: Re: FSSpec from NSString Problems
  • From: Lorenzo Puleo <email@hidden>
  • Date: Wed, 29 Jan 2003 18:00:31 +0100

Hi,
here a always routine to get the FSRef, then you can get from here the
FSSpec. This routine consider the sourceItem is a SymLink, and since you
cannot get an FSRef of a SymLink, it arrive there from its parent folder.


Please consider:
manager = [NSFileManager defaultManager];

- (OSErr)GetFSRef:(NSString*)sourceItem ref:(FSRef*)sourceRef
{
OSErr err;
BOOL isSymLink;

NSDictionary *sourceAttribute = [manager fileAttributesAtPath:sourceItem
traverseLink:NO];
isSymLink = ([sourceAttribute objectForKey:@"NSFileType"] ==
NSFileTypeSymbolicLink);
if(isSymLink){
const char *sourceParentPath;
FSRef sourceParentRef;
HFSUniStr255 sourceFileName;

sourceParentPath = (UInt8*)[[sourceItem
stringByDeletingLastPathComponent] fileSystemRepresentation];
err = FSPathMakeRef(sourceParentPath, &sourceParentRef, NULL);
if(err == noErr){
[[sourceItem lastPathComponent]
getCharacters:sourceFileName.unicode];
sourceFileName.length = [[sourceItem lastPathComponent] length];
if (sourceFileName.length == 0){
err = fnfErr;
}
else err = FSMakeFSRefUnicode(&sourceParentRef,
sourceFileName.length, sourceFileName.unicode, kTextEncodingFullName,
sourceRef);
}
}
else{
err = FSPathMakeRef([sourceItem fileSystemRepresentation],
sourceRef, NULL);
}

return err;
}


--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
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.

  • Prev by Date: MP3 to WAV conversion
  • Next by Date: Re: formatter user input
  • Previous by thread: Re: FSSpec from NSString Problems
  • Next by thread: Changing Pointers Dynamically and Build Warnings
  • Index(es):
    • Date
    • Thread