Back to... Zip-Ada

Source file : flexible_temp_files.adb



   1  package body Flexible_temp_files is
   2  
   3    use Ada.Text_IO;
   4  
   5    procedure Initialize is
   6    begin
   7      Create (radix_temp_file, Out_File);
   8      --  A.8.2 File Management
   9      --  A null string for Name specifies an external file that is not
  10      --  accessible after the completion of the main program (a temporary file).
  11      --
  12      --  NB: at least on ObjectAda, the temporary file is even not accessible
  13      --  after Close, that is before completion of main program. So we need
  14      --  to keep one temporary file open and take its name as radix for other ones.
  15    end Initialize;
  16  
  17    function Radix return String is
  18      s : constant String := Name (radix_temp_file);
  19      --  GNAT & ObjectAda give the temporary file name; other compilers/systems
  20      --  may have not a usable name and raise Use_Error (A.8.2, 23).
  21      dot : Integer := s'Last + 1;
  22    begin
  23      if s = "" then
  24        return s;
  25      end if;
  26      for i in reverse s'Range loop
  27        if s (i) = '.' then
  28          dot := i;
  29          exit;
  30        end if;
  31      end loop;
  32      return s (s'First .. dot - 1);
  33    end Radix;
  34  
  35    procedure Finalize is
  36    begin
  37      Close (radix_temp_file);
  38    end Finalize;
  39  
  40  end Flexible_temp_files;

Web view of Ada source code generated by GNATHTML, project: ALI_Parse version 1.0.
Zip-Ada: Ada library for zip archive files (.zip). Ada programming.
Some news about Zip-Ada and other Ada projects on Gautier's blog.