MoreNavigation/MoreNavigation.c

/*
    File:       MoreNavigation.c
 
    Contains:   Basic Navigation services utilities functionality.
 
    Written by: Quinn
 
    Copyright:  Copyright © 2000 by Apple Computer, Inc., all rights reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
 
         <1>     20/3/00    Quinn   First checked in.
*/
 
/////////////////////////////////////////////////////////////////
 
// MoreIsBetter Setup
 
#include "MoreSetup.h"
 
// Our Prototypes
 
#include "MoreNavigation.h"
 
// Mac OS Interfaces
 
#include <Resources.h>
 
// MIB Prototypes
 
/////////////////////////////////////////////////////////////////
 
extern pascal OSStatus MoreNavExtractSingleReply(const NavReplyRecord *reply, FSSpec *target)
    // See comment in header.
{
    OSStatus err;
    #if MORE_DEBUG
        SInt32 selectionCount;
    #endif
    AEKeyword junkKeyword;
    DescType  junkType;
    Size      junkSize;
 
    MoreAssertQ((AECountItems(&reply->selection, &selectionCount) == noErr) && (selectionCount == 1));
    err = AEGetNthPtr(&reply->selection, 1, typeFSS, &junkKeyword, &junkType, target, sizeof(*target), &junkSize);
    if (err == noErr) {
        MoreAssertQ(junkType == typeFSS && junkSize == sizeof(FSSpec));
        if (target->name[0] == 0) {
            err = FSMakeFSSpec(target->vRefNum, target->parID, target->name, target);   // Guard against potential Nav braindeadedness.
        }
    }
    return err;
}