implemented some functions h2-io-file.
renamed h2-sysapi to h2-os
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
with H2.Sysapi;
|
||||
with H2.OS;
|
||||
|
||||
generic
|
||||
type Slim_Character is (<>);
|
||||
@ -7,31 +7,36 @@ generic
|
||||
type Wide_String is array(System_Index range<>) of Wide_Character;
|
||||
with function Slim_To_Wide (Slim: in Slim_String) return Wide_String;
|
||||
with function Wide_To_Slim (Wide: in Wide_String) return Slim_String;
|
||||
|
||||
with function Sequence_Length (Slim: in Slim_Character) return System_Length;
|
||||
|
||||
package H2.IO is
|
||||
|
||||
package Sysapi is new H2.Sysapi (Slim_Character, Wide_Character, Slim_String, Wide_String, Slim_To_Wide, Wide_To_Slim);
|
||||
package OS is new H2.OS (Slim_Character, Wide_Character, Slim_String, Wide_String, Slim_To_Wide, Wide_To_Slim);
|
||||
|
||||
package File is
|
||||
|
||||
subtype Flag_Record is Sysapi.File.Flag_Record;
|
||||
subtype Flag_Record is OS.File.Flag_Record;
|
||||
subtype Flag_Bits is OS.File.Flag_Bits;
|
||||
|
||||
FLAG_READ: constant := Sysapi.File.FLAG_READ;
|
||||
FLAG_WRITE: constant := Sysapi.File.FLAG_WRITE;
|
||||
FLAG_CREATE: constant := Sysapi.File.FLAG_CREATE;
|
||||
FLAG_EXCLUSIVE: constant := Sysapi.File.FLAG_EXCLUSIVE;
|
||||
FLAG_TRUNCATE: constant := Sysapi.File.FLAG_TRUNCATE;
|
||||
FLAG_APPEND: constant := Sysapi.File.FLAG_APPEND;
|
||||
FLAG_NONBLOCK: constant := Sysapi.File.FLAG_NONBLOCK;
|
||||
FLAG_SYNC: constant := Sysapi.File.FLAG_SYNC;
|
||||
FLAG_NOFOLLOW: constant := Sysapi.File.FLAG_NOFOLLOW;
|
||||
FLAG_READ: constant Flag_Bits := OS.File.FLAG_READ;
|
||||
FLAG_WRITE: constant Flag_Bits := OS.File.FLAG_WRITE;
|
||||
FLAG_CREATE: constant Flag_Bits := OS.File.FLAG_CREATE;
|
||||
FLAG_EXCLUSIVE: constant Flag_Bits := OS.File.FLAG_EXCLUSIVE;
|
||||
FLAG_TRUNCATE: constant Flag_Bits := OS.File.FLAG_TRUNCATE;
|
||||
FLAG_APPEND: constant Flag_Bits := OS.File.FLAG_APPEND;
|
||||
FLAG_NONBLOCK: constant Flag_Bits := OS.File.FLAG_NONBLOCK;
|
||||
FLAG_SYNC: constant Flag_Bits := OS.File.FLAG_SYNC;
|
||||
FLAG_NOFOLLOW: constant Flag_Bits := OS.File.FLAG_NOFOLLOW;
|
||||
|
||||
type File_Record is limited record
|
||||
File: Sysapi.File.File_Pointer := null;
|
||||
Buffer: System_Byte_Array (1 .. 2048);
|
||||
Last: System_Length := System_Length'First;
|
||||
end record;
|
||||
type File_Buffer is private;
|
||||
type File_Record is limited private;
|
||||
|
||||
|
||||
procedure Set_Flag_Bits (Flag: in out Flag_Record;
|
||||
Bits: in Flag_Bits) renames OS.File.Set_Flag_Bits;
|
||||
|
||||
procedure Clear_Flag_Bits (Flag: in out Flag_Record;
|
||||
Bits: in Flag_Bits) renames OS.File.Clear_Flag_Bits;
|
||||
|
||||
procedure Open (File: in out File_Record;
|
||||
Name: in Slim_String;
|
||||
@ -47,21 +52,43 @@ package H2.IO is
|
||||
|
||||
procedure Read (File: in out File_Record;
|
||||
Buffer: in out Slim_String;
|
||||
Last: out System_Length);
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Read (File: in out File_Record;
|
||||
Buffer: in out Wide_String;
|
||||
Last: out System_Length);
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Read_Line (File: in out File_Record;
|
||||
Buffer: in out Slim_String;
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Read_Line (File: in out File_Record;
|
||||
Buffer: in out Wide_String;
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Write (File: in out File_Record;
|
||||
Buffer: in Slim_String;
|
||||
Last: out System_Length);
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Write (File: in out File_Record;
|
||||
Buffer: in Wide_String;
|
||||
Last: out System_Length);
|
||||
Length: out System_Length);
|
||||
|
||||
procedure Flush (File: in out File_Record);
|
||||
|
||||
private
|
||||
type File_Buffer is record
|
||||
Data: System_Byte_Array (1 .. 2048); -- TODO: determine the best size
|
||||
Length: System_Length := 0;
|
||||
end record;
|
||||
|
||||
type File_Record is limited record
|
||||
File: OS.File.File_Pointer := null;
|
||||
Rbuf: File_Buffer;
|
||||
Wbuf: File_Buffer;
|
||||
EOF: Standard.Boolean := false;
|
||||
end record;
|
||||
|
||||
end File;
|
||||
|
||||
end H2.IO;
|
||||
|
Reference in New Issue
Block a user