with Ada.Streams; use Ada.Streams;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Calendar, Interfaces;
package Zip_Streams is
type Time is private;
type Root_Zipstream_Type is abstract new Ada.Streams.Root_Stream_Type with null record;
type Zipstream_Class is access all Root_Zipstream_Type'Class;
procedure Set_Index (S : access Root_Zipstream_Type;
To : Positive) is abstract;
function Index (S : access Root_Zipstream_Type) return Integer is abstract;
function Size (S : access Root_Zipstream_Type) return Integer is abstract;
procedure SetName(S : access Root_Zipstream_Type;
Name : String) is abstract;
function GetName(S : access Root_Zipstream_Type)
return String is abstract;
procedure SetTime(S : access Root_Zipstream_Type;
ModificationTime : Time) is abstract;
procedure SetTime(S : Zipstream_Class;
ModificationTime : Ada.Calendar.Time);
function GetTime(S : access Root_Zipstream_Type)
return Time is abstract;
function GetTime(S : Zipstream_Class)
return Ada.Calendar.Time;
function End_Of_Stream (S : access Root_Zipstream_Type)
return Boolean is abstract;
type Unbounded_Stream is new Root_Zipstream_Type with private;
procedure Get (Str : Unbounded_Stream; Unb : out Unbounded_String);
procedure Set (Str : in out Unbounded_Stream; Unb : Unbounded_String);
type ZipFile_Stream is new Root_Zipstream_Type with private;
procedure Open (Str : in out ZipFile_Stream; Mode : File_Mode);
procedure Create (Str : in out ZipFile_Stream; Mode : File_Mode);
procedure Close (Str : in out ZipFile_Stream);
package Calendar is
function Convert(date : in Ada.Calendar.Time) return Time;
function Convert(date : in Time) return Ada.Calendar.Time;
subtype DOS_Time is Interfaces.Unsigned_32;
function Convert(date : in DOS_Time) return Time;
function Convert(date : in Time) return DOS_Time;
use Ada.Calendar;
procedure Split
(Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Seconds : out Day_Duration);
function Time_Of
(Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration := 0.0) return Time;
end Calendar;
private
type Time is new Interfaces.Unsigned_32;
some_time: constant Time:= 16789 * 65536;
type Unbounded_Stream is new Root_Zipstream_Type with
record
Unb : Unbounded_String;
Loc : Integer := 1;
Name : Unbounded_String;
ModificationTime : Time := some_time;
end record;
procedure Read
(Stream : in out Unbounded_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
procedure Write
(Stream : in out Unbounded_Stream;
Item : Stream_Element_Array);
procedure Set_Index (S : access Unbounded_Stream; To : Positive);
function Index (S : access Unbounded_Stream) return Integer;
function Size (S : access Unbounded_Stream) return Integer;
procedure SetName (S : access Unbounded_Stream; Name : String);
function GetName(S : access Unbounded_Stream) return String;
procedure SetTime(S : access Unbounded_Stream;
ModificationTime : Time);
function GetTime(S : access Unbounded_Stream) return Time;
function End_Of_Stream (S : access Unbounded_Stream) return Boolean;
type ZipFile_Stream is new Root_Zipstream_Type with
record
File : File_Type;
Name : Unbounded_String;
ModificationTime : Time := some_time;
end record;
procedure Read
(Stream : in out ZipFile_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
procedure Write
(Stream : in out ZipFile_Stream;
Item : Stream_Element_Array);
procedure Set_Index (S : access ZipFile_Stream; To : Positive);
function Index (S : access ZipFile_Stream) return Integer;
function Size (S : access ZipFile_Stream) return Integer;
procedure SetName (S : access ZipFile_Stream; Name : String);
function GetName(S : access ZipFile_Stream) return String;
procedure SetTime(S : access ZipFile_Stream;
ModificationTime : Time);
function GetTime(S : access ZipFile_Stream) return Time;
function End_Of_Stream (S : access ZipFile_Stream) return Boolean;
end Zip_Streams;