with System;
with Interfaces.C;
with Interfaces.C.Strings;

use Interfaces.C;

generic

   type T (<>) is private;

   with function Is_Mounted (State : T) return Boolean;
   with function Is_Open (State : T) return Boolean
   with
      Post => (if Is_Open'Result then Is_Mounted (State));

   Initial : T;

   with procedure Mount
     (State    : in out T;
      Part_Len : in     Partition_Length;
      Success  :    out Boolean)
   with
      Pre => not Is_Mounted (State),
      Post => Success = Is_Mounted (State);

   with procedure Open
     (State       : in out T;
      File_Len    :    out File_Length;
      File_Path   : in     String;
      Success     : out    Boolean)
   with
      Pre => Is_Mounted (State) and not Is_Open (State),
      Post => Success = Is_Open (State);

   with procedure Close (State : in out T)
   with
      Pre => Is_Open (State),
      Post => Is_Mounted (State);

   with procedure Read
     (State    : in out T;
      File_Len : in     File_Length;
      File_Pos : in out File_Offset;
      Buf      :    out Buffer_Type;
      Len      :    out Natural)
   with
      Pre => Is_Open (State),
      Post => Is_Open (State);

package FS.FILO.VFS is

   function C_Mount return int;

   function C_Open (File_Path : Strings.chars_ptr) return int;
   procedure C_Close;
   
   function C_Read (Buf : System.Address; Len : int) return int;

end FS.FILO.VFS;
