Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: 1 [2]   Go Down

Author Topic: mounting and unmounting image files programmatically  (Read 8542 times)

OS923

  • 512 MB
  • *****
  • Posts: 888
Re: mounting and unmounting image files programmatically
« Reply #20 on: October 16, 2020, 11:00:56 AM »

Code: [Select]
//========================================
// 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);

Code: [Select]
//========================================
// 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;
}
Logged

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4680
  • just a number
Re: mounting and unmounting image files programmatically
« Reply #21 on: October 16, 2020, 09:15:17 PM »

In what version of OS X are you having the problem?

if i unmount 1 of many partitions of a firewire HD in 10.4.11, the whole disk is put to sleep.
Logged
insert arbitrary signature here

macarone

  • 64 MB
  • ****
  • Posts: 108
  • New Member
Re: mounting and unmounting image files programmatically
« Reply #22 on: October 17, 2020, 03:52:48 AM »

In what version of OS X are you having the problem?

if i unmount 1 of many partitions of a firewire HD in 10.4.11, the whole disk is put to sleep.

I have checked this on a G5:

Booted into  OS 10.5.8 the situation you describe does not exist. When trying to unmount a single partition, I'm given the choice of unmounting all or just the single partition, and whatever I select happens.

Booted into OS 10.4.11 I have been able to duplicate what you describe, when using Command-E or File/Eject. Even though the in File/Eject is for the specific volume highlighted, all volumes on the FireWire device are ejected.  Due to Covid-19m  I'm not at home, and do not have access to my G4 MDD, but I seem to recall it did not happen there, maybe I'm not remebering it correctly. I vaguely  remember that power to FireWire ports was changed from G4 to G5 to make possible charging iPhones even when the computer is off on G5s.

I did find a workaround in Tiger:

Open DiskUtilities and select the volume you want to un-mount on the left panel. Then click the Unmount button at the top. When I did it THIS way, only the single partition was un-mounted.

Logged

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4680
  • just a number
Re: mounting and unmounting image files programmatically
« Reply #23 on: October 18, 2020, 06:53:45 PM »

yeah, you can use diskutil in emergency cases. :)

i suspect that th finder behaviour os a left over f rom OS9 and OSX 10.0, which coundnt handle sleep via firewire.
Logged
insert arbitrary signature here

OS923

  • 512 MB
  • *****
  • Posts: 888
Re: mounting and unmounting image files programmatically
« Reply #24 on: October 19, 2020, 06:52:16 AM »

Do error codes under OS9 and OSX have the same meaning? I could not find -1310 code in the pre OSX error listings.

not only that - today it gives me a different error number - with 5 digits.
-1310 = data too big
Logged
Pages: 1 [2]   Go Up

Recent Topics