with ConsAKD; use ConsAKD; with Errors; with Program_Control; package body FileAKD is ---------------------------------------------------------------------- -- Copyright (C) 1994 David Wallace Croft. All rights reserved. ---------------------------------------------------------------------- procedure Demo is ---------------------------------------------------------------------- begin Put_Line ( Copyright ); New_Line; Put_Line ( Description ); New_Line; Put_Line ( "No demonstration is currently available." ); Pause; end Demo; ---------------------------------------------------------------------- -- File I/O ---------------------------------------------------------------------- function Append ( File_From : string; File_To : string; File_Temp : string := "FileAKD.Tmp"; Delete_From : boolean := false ) return boolean is ---------------------------------------------------------------------- use Program_Control; use Errors; Error : Extended_Errors; begin Error := MSDOS ( "copy " & File_To & " + " & File_From & " " & File_Temp & " > nul" ); if Error /= Errors.OK then return false; end if; begin Delete ( File_To ); exception when Name_Error => null; end; Error := MSDOS ( "ren " & File_Temp & " " & File_To ); if Error /= Errors.OK then return false; end if; if Delete_From then Delete ( File_From ); end if; return true; exception when others => return false; end Append; procedure Copy ( From : in string; To : in string ) is ---------------------------------------------------------------------- -- Limited by length of Line_Type ---------------------------------------------------------------------- Last : natural; Line : Line_Type; Copied : File_Type; Copy : File_Type; begin Open ( Copied, In_File , From ); Create ( Copy , Out_File, To ); loop exit when End_Of_File ( Copied ); Get_Line ( Copied, Line, Last ); Put_Line ( Copy , Line ( 1..Last ) ); end loop; Close ( Copied ); Close ( Copy ); end Copy; procedure Delete ( File_Name : in string ) is ---------------------------------------------------------------------- File : File_Type; begin Open ( File, Out_File, File_Name ); Delete ( File ); end Delete; ---------------------------------------------------------------------- ---------------------------------------------------------------------- end FileAKD;