DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦da5fdeac2⟧ Ada Source

    Length: 11264 (0x2c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Mac_Files, seg_0255f0

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Bit_Ops;
with Errors;
with Files;
with Mac_Path;
with Mac_Text;
with Mac_Types;
with System;
with Unchecked_Conversion;
package body Mac_Files is

    Home_Directory_Name : Mac_Types.Str255 := (others => Mac_Types.Nul);

    function As_Stringptr is new Unchecked_Conversion
                                    (Source => System.Address,
                                     Target => Mac_Types.Stringptr);  
    function As_Varlongint is new Unchecked_Conversion
                                     (Source => System.Address,
                                      Target => Mac_Types.Varlongint);
    function As_Wdpbptr is new Unchecked_Conversion (Source => System.Address,
                                                     Target => Files.Wdpbptr);

    function As_Cinfopbptr is new Unchecked_Conversion
                                     (Source => System.Address,
                                      Target => Files.Cinfopbptr);

    procedure Set_User_Home (Name : Mac_Types.Str255) is
    begin
        Home_Directory_Name := Name;
    end Set_User_Home;

    procedure Set_Current_User_Home is
        Err : Mac_Types.Oserr;
        S : Mac_Types.Str255 := Home_Directory_Name;
    begin
        Err := Files.Hsetvol (As_Stringptr (S'Address), 0, 0);
    end Set_Current_User_Home;

    function Create_Sub_Directories
                (Name : Mac_Text.Text) return Mac_Types.Oserr is  
        S : Mac_Types.Str255;
        Exists : Boolean;
        Err : Mac_Types.Oserr;
        Parent_Dir_Id : Mac_Types.Longint;
        A_Wdpbrec : Files.Wdpbrec;
    begin
        Mac_Path.Get_Mac_Root_Directory (Name, S, Exists);
        if Exists then
            Err := Files.Setvol (As_Stringptr (S'Address), 0);
            if Err /= Mac_Types.Noerr then
                return Err;
            end if;
        end if;
        A_Wdpbrec.Iocompletion := null;
        A_Wdpbrec.Ionameptr := null;
        Err := Files.Pbhgetvol (Paramblock => As_Wdpbptr (A_Wdpbrec'Address),
                                Async => False);
        if Err /= Mac_Types.Noerr then
            return Err;
        end if;
        Parent_Dir_Id := A_Wdpbrec.Iowddirid;

        for Sub_Dir in Mac_Path.Index loop
            Mac_Path.Get_Mac_Sub_Directory (Name, Sub_Dir, S, Exists);
            exit when not Exists;
            Err := Files.Setvol (As_Stringptr (S'Address), 0);
            if Err /= Mac_Types.Noerr then
                Err := Files.Dircreate
                          (Vrefnum => 0,
                           Parentdirid => Parent_Dir_Id,
                           Directoryname => S,
                           Createddirid =>
                              As_Varlongint (Parent_Dir_Id'Address));
                if Err /= Mac_Types.Noerr then
                    return Err;
                end if;
            end if;
            Err := Files.Setvol (As_Stringptr (S'Address), 0);
            if Err /= Mac_Types.Noerr then
                return Err;
            end if;
        end loop;

        return Mac_Types.Noerr;
    end Create_Sub_Directories;

    function Create_Directory (Name : Mac_Text.Text) return Mac_Types.Oserr is
        S : Mac_Types.Str255;
        Exists : Boolean;
        Err : Mac_Types.Oserr;
        Parent_Dir_Id : Mac_Types.Longint;
        A_Wdpbrec : Files.Wdpbrec;
    begin
        A_Wdpbrec.Iocompletion := null;
        A_Wdpbrec.Ionameptr := null;
        Err := Files.Pbhgetvol (Paramblock => As_Wdpbptr (A_Wdpbrec'Address),
                                Async => False);
        if Err /= Mac_Types.Noerr then
            return Err;
        end if;
        Parent_Dir_Id := A_Wdpbrec.Iowddirid;

        Mac_Path.Get_Mac_Name (Name, S, Exists);
        if not Exists then
            return Errors.Bdnamerr;
        end if;
        return Files.Dircreate (0, Parent_Dir_Id, S,
                                As_Varlongint (Parent_Dir_Id'Address));
    end Create_Directory;

    function Create_File (Name : Mac_Text.Text) return Mac_Types.Oserr is
        S : Mac_Types.Str255;
        Exists : Boolean;
        Err : Mac_Types.Oserr;
        Parent_Dir_Id : Mac_Types.Longint;
        A_Wdpbrec : Files.Wdpbrec;
    begin
        A_Wdpbrec.Iocompletion := null;
        A_Wdpbrec.Ionameptr := null;
        Err := Files.Pbhgetvol (Paramblock => As_Wdpbptr (A_Wdpbrec'Address),
                                Async => False);
        if Err /= Mac_Types.Noerr then
            return Err;
        end if;
        Parent_Dir_Id := A_Wdpbrec.Iowddirid;

        Mac_Path.Get_Mac_Name (Name, S, Exists);
        if not Exists then
            return Errors.Bdnamerr;
        end if;
        return Files.Hcreate (0, Parent_Dir_Id, S,
                              Creator => 16#44544941#, -- DTIA
                              Filetype => 16#54455854# -- TEXT
                              );
    end Create_File;

    function Delete_File (Name : Mac_Text.Text; Recursive : Boolean)
                         return Mac_Types.Oserr is  
        type Dircinfopbptr is access Files.Dircinfopbrec;
        type Hfilecinfopbptr is access Files.Hfilecinfopbrec;

        function As_Hfilecinfopbptr is
           new Unchecked_Conversion (Source => System.Address,
                                     Target => Hfilecinfopbptr);

        function As_Dircinfopbptr is
           new Unchecked_Conversion (Source => System.Address,
                                     Target => Dircinfopbptr);

        Err, Err2 : Mac_Types.Oserr := Mac_Types.Noerr;  
        S : Mac_Types.Str255 := Mac_Text.Value (Name);
        Pb : Files.Cinfopbrec;
        Filepb : Hfilecinfopbptr := As_Hfilecinfopbptr (Pb'Address);  
        Dirpb : Dircinfopbptr := As_Dircinfopbptr (Pb'Address);

        procedure Enumerate_Catalog (Dirid : Mac_Types.Longint) is
            Folder_Bit : constant Byte_Integer := 2#00001000#;
            Index : Mac_Types.Integer;  
            Parent_Dir_Id : Mac_Types.Longint;
            Dir_Name : Mac_Types.Str255;
        begin
            Index := 1;
            loop
                Pb.Iofdirindex := Index;
                Dirpb.Iodrdirid := Dirid;
                Err := Files.Pbgetcatinfo (As_Cinfopbptr (Pb'Address), False);
                if Err = Mac_Types.Noerr then
                    if Bit_Ops."and"
                          (Byte_Integer (Pb.Ioflattrib), Folder_Bit) /= 0 then  
                        Dir_Name := S;
                        Parent_Dir_Id := Dirpb.Iodrparid;
                        if Recursive then
                            Enumerate_Catalog (Dirid => Dirpb.Iodrdirid);
                        end if;
                        Err2 := Files.Hdelete (Vrefnum => Pb.Iovrefnum,
                                               Dirid => Parent_Dir_Id,
                                               Filename => Dir_Name);
                    else
                        Err2 := Files.Hdelete (Vrefnum => Pb.Iovrefnum,
                                               Dirid => Filepb.Ioflparid,
                                               Filename => S);
                    end if;
                end if;
                Index := Index + 1;
                exit when Err /= Mac_Types.Noerr or Err2 /= Mac_Types.Noerr;
            end loop;
        end Enumerate_Catalog;

    begin  
        Pb.Iocompletion := null;
        Pb.Ionameptr := As_Stringptr (S'Address);
        Pb.Iovrefnum := 0;  
        Enumerate_Catalog (0);
        return Err2;
    end Delete_File;

end Mac_Files;

E3 Meta Data

    nblk1=a
    nid=0
    hdr6=14
        [0x00] rec0=1b rec1=00 rec2=01 rec3=01c
        [0x01] rec0=1d rec1=00 rec2=08 rec3=014
        [0x02] rec0=00 rec1=00 rec2=03 rec3=056
        [0x03] rec0=17 rec1=00 rec2=02 rec3=044
        [0x04] rec0=1d rec1=00 rec2=05 rec3=06a
        [0x05] rec0=1a rec1=00 rec2=04 rec3=040
        [0x06] rec0=17 rec1=00 rec2=07 rec3=03a
        [0x07] rec0=00 rec1=00 rec2=06 rec3=026
        [0x08] rec0=14 rec1=00 rec2=09 rec3=080
        [0x09] rec0=15 rec1=00 rec2=0a rec3=000
    tail 0x217204c3083a2665f19ad 0x42a00088462060003