added some file constants
This commit is contained in:
@ -15,37 +15,42 @@ package body File is
|
||||
procedure sys_close (fd: C.int);
|
||||
pragma Import (C, sys_close, "close");
|
||||
|
||||
INVALID_HANDLE: constant C.int := -1;
|
||||
|
||||
type Posix_File_Record is new File_Record with record
|
||||
Pool: Storage_Pool_Pointer := null;
|
||||
Handle: C.int := Interfaces.C."-"(1);
|
||||
Handle: C.int := INVALID_HANDLE;
|
||||
end record;
|
||||
type Posix_File_Pointer is access all Posix_File_Record;
|
||||
|
||||
function Flag_To_System (Flag: in Flag_Record) return C.int is
|
||||
function Flag_To_System (Bits: in File_Flag_Bits) return C.int is
|
||||
V: C.int := 0;
|
||||
begin
|
||||
return 0;
|
||||
end Flag_To_System;
|
||||
-- if Bits and File_Flag_Read /= 0 then
|
||||
-- V := V or 0;
|
||||
-- end if;
|
||||
-- if Bits and File_Flag_Write /= 0 then
|
||||
-- V := V or 1;
|
||||
-- end if;
|
||||
|
||||
function Mode_To_System (Mode: in Mode_Record) return C.int is
|
||||
begin
|
||||
return 0;
|
||||
end Mode_To_System;
|
||||
return V;
|
||||
end Flag_To_System;
|
||||
|
||||
procedure Open (File: out File_Pointer;
|
||||
Name: in Slim_String;
|
||||
Flag: in Flag_Record;
|
||||
Mode: in Mode_Record;
|
||||
Flag: in File_Flag;
|
||||
Mode: in File_Mode := DEFAULT_FILE_MODE;
|
||||
Pool: in Storage_Pool_Pointer := null) is
|
||||
|
||||
package P is new H2.Pool (Posix_File_Record, Posix_File_Pointer, Pool);
|
||||
F: Posix_File_Pointer;
|
||||
|
||||
|
||||
begin
|
||||
F := P.Allocate;
|
||||
F.Pool := Pool;
|
||||
|
||||
--F.Handle := sys_open (Interfaces.C.char_array(Name & Slim.Character'Val(0)), 0, 0);
|
||||
F.Handle := sys_open (Name, Flag_To_System(Flag), Mode_To_System(Mode));
|
||||
F.Handle := sys_open (Name, Flag_To_System(Flag.Bits), C.int(Mode.Bits));
|
||||
if F.Handle <= -1 then
|
||||
raise Constraint_Error; -- TODO: raise a proper exception.
|
||||
end if;
|
||||
@ -55,9 +60,9 @@ package body File is
|
||||
|
||||
procedure Open (File: out File_Pointer;
|
||||
Name: in Wide_String;
|
||||
Flag: in Flag_Record;
|
||||
Mode: in Mode_Record;
|
||||
Pool: in Storage_Pool_Pointer := null) is
|
||||
Flag: in File_Flag;
|
||||
Mode: in File_Mode := DEFAULT_FILE_MODE;
|
||||
Pool: in Storage_Pool_Pointer := null) is
|
||||
begin
|
||||
Open (File, Wide_To_Slim(Name), Flag, Mode, Pool);
|
||||
end Open;
|
||||
|
Reference in New Issue
Block a user