Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't convert path ~/... to Fsref



I am trying to create/open a file with the origine in posix example "~/Library/Preferences/temp.tiff"
 
I have made a function to convert based on some example I have found...
It works most of the time but seems to failed with the TILDE(~) current user...
The RetStatus is -43 rectory not found...
 
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////
OSStatus FSPathMakeFSSpec (CFilePath & FilePath, FSSpec * OutFSSpec, Boolean * OutIsDirectory )
{
OSStatus        RetStatus;
Str255          PascalPathname;
FSRef           FileRef;
FSCatalogInfo   ThisInfo;
char            PathName [256];
char            FileName [256];
 
    ExtractPath    (PathName, FilePath.m_Filename, 256);
    ExtractFileName(FileName, FilePath.m_Filename, 256);
   
    if((PathName[0]        == 0)
    && (FilePath.m_VRefNum == 0)
    && (FilePath.m_parID   == 0)
    ){
       ConvertStringToPascalStr (OutFSSpec->name,  FileName, 63);
       RetStatus = GetDefaultTempDir(OutFSSpec);
       return RetStatus;
    } else if(PathName[0]  == 0){
       OutFSSpec->vRefNum   = FilePath.m_VRefNum;
       OutFSSpec->parID     = FilePath.m_parID;
       ConvertStringToPascalStr (OutFSSpec->name,  FileName, 63);
       return NO_ERROR;
    }
// *************************************************************************************************
// POINT OF FAILLURE!???
 
    RetStatus  = FSPathMakeRef((const UInt8 *)PathName, &FileRef, OutIsDirectory);
    require_noerr(RetStatus, ExitFSPathMakeFSSpec);
 
// *************************************************************************************************
    RetStatus     = FSGetCatalogInfo(&FileRef, kFSCatInfoVolume | kFSCatInfoNodeID, &ThisInfo, NULL, NULL, NULL);
    require_noerr(RetStatus, ExitFSPathMakeFSSpec);
 
    OutFSSpec->vRefNum   = ThisInfo.volume;
    OutFSSpec->parID     = ThisInfo.nodeID;
 
    ConvertStringToPascalStr (OutFSSpec->name,  FileName, 63);
    ConvertStringToPascalStr (PascalPathname,   PathName, 63);
 
ExitFSPathMakeFSSpec:
    return( RetStatus );
}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.