DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

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 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦9cc88b335⟧ TextFile

    Length: 7499 (0x1d4b)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

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;