Mailing Lists: Apple Mailing Lists

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

Re: Getting parent of nonexistent file



"Steve Mills" <email@hidden> wrote:

If spec refers to a file that does NOT exist, but the parent directory (spec->parID) DOES exist, should this work?

OSErr FSpGetParent(FSSpec* spec)
{
    CInfoPBRec        pb;
    DirInfo*          dirRec = (DirInfo*)&pb;
    OSErr             err;
    Str255            s;

    PStrCopy(spec->name, s);
    dirRec->ioCompletion = nil;
    dirRec->ioNamePtr = s;
    dirRec->ioVRefNum = spec->vRefNum;
    dirRec->ioFDirIndex = -1;
    dirRec->ioDrDirID = spec->parID;
    err = PBGetCatInfoSync(&pb);

    if(err == noErr)
        err = FSMakeFSSpec(dirRec->ioVRefNum, dirRec->ioDrParID, s, spec);

    return err;
}

Should err returned from PBGetcatInfoSync be noErr or fnfErr, and should ioDrParID contain the parent directory upon completion?

I'd say that PBGetcatInfoSync should return fnfErr. But this is the hard way anyway. To get the parent, call FSMakeFSSpec( spec->vRefNum, spec->parID, "\p", &parentSpec ).
--
James W. Walker, ScriptPerfection Enterprises, Inc.
<http://www.write-brain.com/>
_______________________________________________
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
References: 
 >Getting parent of nonexistent file (From: "Steve Mills" <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.