//========================================
// File: MountToastImage.h
//========================================
#pragma once
void main();
OSErr Mount1(ConstStringPtr path);
OSErr Mount2(AliasHandle alias);
OSErr Mount3(AliasHandle alias,
const AEAddressDesc &target);
OSErr Mount4(AliasHandle alias,
AppleEvent &appleEvent);
//========================================
// File: MountToastImage.cp
//========================================
#include "MountToastImage.h"
void main()
{
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
const OSErr err=Mount1("\pOpstart:MountToastImage:Documentation:DotDotTwoV2.iso");
}
OSErr Mount1(ConstStringPtr const path)
{
AliasHandle alias;
OSErr err=::NewAliasMinimalFromFullPath(*path,
path+1,
nil,
nil,
&alias);
if (err)
{
return err;
}
const OSErr err2=Mount2(alias);
Handle const h=reinterpret_cast<Handle>(alias);
::DisposeHandle(h);
err=::MemError();
if (err)
{
return err;
}
if (err2)
{
return err2;
}
return noErr;
}
OSErr Mount2(AliasHandle const alias)
{
const OSType toastCreator='CDr3';
AEAddressDesc target;
OSErr err=::AECreateDesc(typeApplSignature,
&toastCreator,
sizeof(OSType),
&target);
if (err)
{
return err;
}
const OSErr err3=Mount3(alias,
target);
err=::AEDisposeDesc(&target);
if (err)
{
return err;
}
if (err3)
{
return err3;
}
return noErr;
}
OSErr Mount3(AliasHandle const alias,
const AEAddressDesc &target)
{
AppleEvent appleEvent;
appleEvent.descriptorType=typeNull;
appleEvent.dataHandle=nil;
OSErr err=::AECreateAppleEvent('CDr3',
'mntI',
&target,
kAutoGenerateReturnID,
kAnyTransactionID,
&appleEvent);
if (err)
{
return err;
}
const OSErr err4=Mount4(alias,
appleEvent);
err=::AEDisposeDesc(&appleEvent);
if (err)
{
return err;
}
if (err4)
{
return err4;
}
return noErr;
}
OSErr Mount4(AliasHandle const alias,
AppleEvent &appleEvent)
{
AEDesc aliasDesc;
aliasDesc.descriptorType=typeAlias;
aliasDesc.dataHandle=reinterpret_cast<Handle>(alias);
OSErr err=::AEPutParamDesc(&appleEvent,
keyDirectObject,
&aliasDesc);
if (err)
{
return err;
}
err=::AESend(&appleEvent,
nil,
kAENoReply bitor kAEAlwaysInteract bitor kAECanSwitchLayer,
kAENormalPriority,
kAEDefaultTimeout,
nil,
nil);
if (err)
{
return err;
}
return noErr;
}