|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 7271 (0x1c67)
Types: TextFile
Names: »B«
└─⟦516dceb10⟧ Bits:30000751 8mm tape, Rational 1000, RCI_VADS
└─⟦9a14c9417⟧ »DATA«
└─⟦this⟧
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;