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

⟦c72b2bedb⟧ Ada Source

    Length: 11264 (0x2c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Create_Remote_Directory, seg_03be0a, separate Library_Extensions

Derivation

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

E3 Source Code



with Sparc_Strings;
with String_Utilities;
separate (Library_Extensions)  
procedure Create_Remote_Directory  
             (Remote_Directory  :        String;
              Remote_Machine    :        String;
              Remote_Connection : in out Rci.Context;
              Status            : in out Simple_Status.Condition) is

    package Su renames String_Utilities;
    Previous_Separator : Natural;
    Path_Exists        : Boolean         := False;
    Create_Dir_Command : constant String := "mkdir " & Remote_Directory;

begin
    Log.Put_Line  
       (Message => "Creating remote directory = " & Remote_Directory,
        Kind    => Profile.Note_Msg);

    -- SANITY CHECK
    -- force remote directory strings to be fully qualified path names
    -- in Unix this means that they MUST begin with a forward slash ('/')

    if (Su.Locate  
           (Fragment    => Sparc_Strings.Directory_Separator,
            Within      => Remote_Directory,
            Ignore_Case => True) /= 1) then

        Set_Status  
           (Status     => Status,
            Error_Type => "Sanity_Error",
            Message    => "Remote_Directory string must begin with a " &
                             Sparc_Strings.Directory_Separator & ".",
            Severity   => Simple_Status.Fatal);

        return;
    end if;


    -- check to see if the requested directory already exists
    Directory_Exists  
       (Remote_Machine    => Remote_Machine,
        Remote_Directory  => Remote_Directory,
        Remote_Connection => Remote_Connection,
        Status            => Status,
        Exists            => Path_Exists);



    if not Simple_Status.Error (Status) then
        if Path_Exists then
            Log.Put_Line  
               (Message => "The directory " & Remote_Directory &  
                              " already exits.",  
                Kind    => Profile.Warning_Msg);
        else

            Previous_Separator :=  
               Su.Reverse_Locate  
                  (Fragment    => Sparc_Strings.Directory_Separator,
                   Within      => Remote_Directory,
                   Ignore_Case => True);

            if Previous_Separator = 0 then

                Set_Status  
                   (Status     => Status,
                    Error_Type => "Create_Directory_Error",
                    Message    =>  
                       "Remote_Directory string does not begin with a """ &
                          Sparc_Strings.Directory_Separator & """",
                    Severity   => Simple_Status.Problem);

            elsif Previous_Separator = 1 then

                -- we are at the root of the path, there is no parent to check so just
                -- create the child
                if not Simple_Status.Error (Status) then
                    -- the parent should now exist, so create the child
                    Rci.Execute_Command                        (Command_Line          => Create_Dir_Command,
                        Remote_Connection     => Remote_Connection,
                        Status                => Status,
                        Error_Pattern         => "",
                        Parse_Error_Output    => False,
                        Parse_Standard_Output => False,
                        Show_Parsed_Output    => True,
                        Trace_Command         => Trace_Rci_Commands);

                    if Simple_Status.Error (Status) then
                        Log.Put_Line  
                           (Message => Simple_Status.Message (Status),  
                            Kind    => Profile.Error_Msg);
                        Set_Status  
                           (Status     => Status,
                            Error_Type => "Remote_Operation_Error",
                            Message    =>
                               "Creation of root directory failed.  " &  
                                  "Unable to create remote directory_path.",
                            Severity   => Simple_Status.Problem);
                    end if;
                end if;

            else

                declare
                    Parent_Directory : constant String :=
                       Remote_Directory (Remote_Directory'First ..
                                            Previous_Separator - 1);
                    Parent_Exists    : Boolean         := False;

                begin

                    -- check to see if the parent directory in the path exists
                    Directory_Exists  
                       (Remote_Machine    => Remote_Machine,
                        Remote_Directory  => Parent_Directory,
                        Remote_Connection => Remote_Connection,
                        Status            => Status,
                        Exists            => Parent_Exists);

                    if not Simple_Status.Error (Status) then
                        if not Parent_Exists then
                            -- if the parent directory doesn't exist, recursively call
                            -- this routine to create it.
                            Create_Remote_Directory  
                               (Remote_Directory  => Parent_Directory,
                                Remote_Machine    => Remote_Machine,
                                Remote_Connection => Remote_Connection,
                                Status            => Status);
                        end if;

                        if not Simple_Status.Error (Status) then
                            -- the parent should now exist, so create the child
                            Rci.Execute_Command  
                               (Command_Line          => Create_Dir_Command,
                                Remote_Connection     => Remote_Connection,
                                Status                => Status,
                                Error_Pattern         => "",
                                Parse_Error_Output    => False,
                                Parse_Standard_Output => False,
                                Show_Parsed_Output    => True,
                                Trace_Command         => Trace_Rci_Commands);

                            if Simple_Status.Error (Status) then
                                Log.Put_Line  
                                   (Message => Simple_Status.Message (Status),  
                                    Kind    => Profile.Error_Msg);
                                Set_Status  
                                   (Status     => Status,
                                    Error_Type => "Remote_Operation_Error",
                                    Message    =>
                                       "Creation of subdirectory " &
                                          Remote_Directory & " failed.  " &  
                                          "Unable to create remote directory_path.",
                                    Severity   => Simple_Status.Problem);
                            end if;
                        end if;
                    end if;
                end;
            end if;
        end if;
    end if;
exception
    when others =>
        Unhandled_Exception (Status, "Create_Remote_Directory");
end Create_Remote_Directory;

E3 Meta Data

    nblk1=a
    nid=0
    hdr6=14
        [0x00] rec0=1c rec1=00 rec2=01 rec3=004
        [0x01] rec0=00 rec1=00 rec2=0a rec3=01e
        [0x02] rec0=1f rec1=00 rec2=02 rec3=026
        [0x03] rec0=17 rec1=00 rec2=03 rec3=002
        [0x04] rec0=11 rec1=00 rec2=04 rec3=092
        [0x05] rec0=18 rec1=00 rec2=05 rec3=03a
        [0x06] rec0=00 rec1=00 rec2=09 rec3=016
        [0x07] rec0=10 rec1=00 rec2=06 rec3=078
        [0x08] rec0=11 rec1=00 rec2=07 rec3=016
        [0x09] rec0=0d rec1=00 rec2=08 rec3=000
    tail 0x215348002856574b1d437 0x42a00088462062803