SetLockBit.c

/*
    File:       SetLockBit.c
 
    Contains:   Sample to demonstrate setting the file lock bit.  This action
                atom code resource must be called through a post installation action
                atom.  In the selector field, pass in the name of the target 'infs'
                resource id.  The code resource gets the resource, converts the partial
                path name field to a pascal string, then calls, SetFLock.  A result of 
                true is always returned so as not to abort the installation.
        
                This action atom is designed for use by both Installer 3.2 and 3.3
 
    Written by: Rich Kubota 
 
    Copyright:  Copyright © 1990-1999 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):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
#if 0
 
C -r -b  SetLockBit.c
Link -ra =resPurgeable -t rsrc -c RSED -rt infn=10000 ¶
    -m SETLOCKBIT -sg SetLockBit ¶
    SetLockBit.c.o ¶
    "{Libraries}"Interface.o ¶
    -o SetLockBit.rsrc
 
#endif
 
#include <Types.h>
#include <Resources.h>
#include <Files.h>
#include "ActionAtomIntf.h"
 
/* define record structure of 'infs' resource so that we can access the target file path */
 
struct infsRec {
    long    fileType;
    long    creator;
    long    creationDate;
    short   fileSpecFlags;
    Str255  pathName;
};
 
typedef struct infsRec infsRec;
typedef infsRec **infsHdl;
 
/* protoypes */
void    makePStr(char *fm, char *to);
 
 
pascal Boolean  SETLOCKBIT(AAPBRecPtr myAAPBPtr)
{
    OSErr   err;
    infsHdl resH;
    
    resH = (infsHdl)GetResource('infs', myAAPBPtr->aaRefCon);
    if (resH)
        err = SetFLock((*resH)->pathName, myAAPBPtr->targetVRefNum);
    return true;
}