---------------------------------------------------------------------------- -- Copyright (C) 2015-2017, AdaCore -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are -- met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in -- the documentation and/or other materials provided with the -- distribution. -- 3. Neither the name of the copyright holder nor the names of its -- contributors may be used to endorse or promote products derived -- from this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- ----------------------------------------------------------------------------
type Any_Directory_Handle is access all Directory_Handle'Class;
type Any_File_Handle is access all File_Handle'Class;
type Any_Filesystem_Driver is access all Filesystem_Driver'Class;
type Any_Node_Handle is access all Node_Handle'Class;
function Basename (This : Node_Handle) return String
procedure Close (This : in out Directory_Handle)
Closes the handle, and free the associated resources.
procedure Close (This : in out File_Handle)
procedure Close (This : in out Filesystem_Driver)
procedure Close (This : in out Node_Handle)
function Create_File (This : in out Filesystem_Driver;
Path : String)
return Status_Code
type Directory_Handle is limited interface;
type File_Handle is limited interface;
type File_Mode is (Read_Only, Write_Only, Read_Write);
type File_Size is new HAL.UInt64;
Modern fs all support 64-bit file size. Only old or limited ones support max 32-bit (FAT in particular). So let's see big and not limit ourselves in this API with 32-bit only.
type Filesystem_Driver is limited interface;
function Flush
(This : in out File_Handle)
return Status_Code
function Get_FS
(This : Directory_Handle) return Any_Filesystem_Driver
Return the filesystem_Driver the handle belongs to.
function Get_FS
(This : in out File_Handle) return Any_Filesystem_Driver
function Get_FS (This : Node_Handle) return Any_Filesystem_Driver
function Is_Hidden (This : Node_Handle) return Boolean
function Is_Read_Only (This : Node_Handle) return Boolean
function Is_Subdirectory (This : Node_Handle) return Boolean
function Is_Symlink (This : Node_Handle) return Boolean
function Mode
(This : File_Handle) return File_Mode
type Node_Handle is interface;
function Offset
(This : File_Handle)
return File_Size
function Open
(This : in out Filesystem_Driver;
Path : String;
Handle : out Any_Directory_Handle)
return Status_Code
Open a new Directory Handle at the given Filesystem_Driver Path
function Open
(This : in out Filesystem_Driver;
Path : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code
Open a new File Handle at the given Filesystem_Driver Path
function Open
(This : Node_Handle;
Name : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code
function Read
(This : in out Directory_Handle;
Handle : out Any_Node_Handle)
return Status_Code
Reads the next directory entry. If no such entry is there, an error code is returned in Status.
function Read
(This : in out File_Handle;
Addr : System.Address;
Length : in out File_Size)
return Status_Code
function Remove_Directory (This : in out Filesystem_Driver;
Path : String)
return Status_Code
Remove the directory located at Path in the This filesystem_Driver
procedure Reset (This : in out Directory_Handle)
Resets the handle to the first node
function Root_Node
(This : in out Filesystem_Driver;
As : String;
Handle : out Any_Node_Handle)
return Status_Code
Open a new Directory Handle at the given Filesystem_Driver Path
function Seek
(This : in out File_Handle;
Origin : Seek_Mode;
Amount : in out File_Size)
return Status_Code
type Seek_Mode is
(
From_Start,
From_End,
Forward,
Backward);
Seek from the end of the file, backward
Seek from the current position, forward
Seek from the current position, backward
function Size
(This : File_Handle) return File_Size
function Size (This : Node_Handle) return File_Size
type Status_Code is
(OK,
Non_Empty_Directory,
Disk_Error,
Disk_Full,
Internal_Error,
Drive_Not_Ready,
No_Such_File,
No_Such_Path,
Not_Mounted,
Invalid_Name,
Access_Denied,
Already_Exists,
Invalid_Object_Entry,
Write_Protected,
Invalid_Drive,
No_Filesystem,
Locked,
Too_Many_Open_Files,
Invalid_Parameter,
Input_Output_Error,
No_MBR_Found,
No_Partition_Found,
No_More_Entries,
Read_Only_File_System,
Operation_Not_Permitted);
A hardware error occurred in the low level disk I/O
The mount point is invalid
The volume is not a FAT volume
All available handles are used
function Unlink (This : in out Filesystem_Driver;
Path : String)
return Status_Code
Remove the regular file located at Path in the This filesystem_Driver
function Write
(This : in out File_Handle;
Addr : System.Address;
Length : File_Size)
return Status_Code