IsPCExchangeInstalled.c

/*
    File:       IsPCExchangeInstalled.c
    
    Description:This snippet demonstrates the check for the existence of PC Exchange.
                The FSMGlueLib.o file is available on the MacOS SDK CD in the File
                System Manager Libraries folder.
 
 
    Author:     JL
 
    Copyright:  Copyright: © 1996-1999 by Apple Computer, Inc.
                all rights reserved.
    
    Disclaimer: You may incorporate this sample code into your applications without
                restriction, though the sample code has been provided "AS IS" and the
                responsibility for its operation is 100% yours.  However, what you are
                not permitted to do is to redistribute the source as "DSC Sample 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 Code, but that you've made changes.
    
    Change History (most recent first):
                6/25/99 Updated for Metrowerks Codewarror Pro 2.1(KG)
 
*/
 
#include <Gestalt.h>
#include <FSM.h>
 
static  Boolean HasFSM(void);
Boolean IsMacPCExchangeInstalled(void);
 
 
/*
**  HasFSM determines if the File System Manager is available.
*/
static  Boolean HasFSM(void)
{
    long    response;
    Boolean result;
    
    result = false;
    
    /* Make sure the File System Manager is installed */
    if ( Gestalt(gestaltFSAttr, &response) == noErr )
    {
        if ( (response & (1L << gestaltHasFileSystemManager)) != 0 )
        {
            result = true;
        }
    }
    
    return ( result );
}
 
/*****************************************************************************/
 
/*
**  IsMacPCExchangeInstalled determines if Macintosh PC Exchange has installed
**  the MS-DOS foreign file system.
*/
Boolean IsMacPCExchangeInstalled(void)
{
    enum
    {
        kMacPCExchangeFSID = 0x4953 /* file system ID of Macintosh PC Exchange's
                                        MS-DOS file system */
    };
    Boolean result;
    short   bufSize;    /* The size of the FSDRec */
    FSDRec  theFSDRec;  /* The FSDRec */
    
    result = false;     /* default to no Macintosh PC Exchange */
    
    /* Make sure the File System Manager is available */
    if ( HasFSM() )
    {
        bufSize = sizeof(FSDRec);
        if ( GetFSInfo(fsmGetFSInfoByFSID, kMacPCExchangeFSID, &bufSize, &theFSDRec) == noErr )
        {
            result = true;
        }
    }
    
    return ( result );
}
 
/*****************************************************************************/
 
/* Test code */
void    main(void)
{
    if ( IsMacPCExchangeInstalled() )
    {
        DebugStr("\pMacintosh PC Exchange is installed");
    }
    else
    {
        DebugStr("\pMacintosh PC Exchange is NOT installed");
    }
}