HAL.Filesystem

Entities

Simple Types

Interface Types

Access Types

Subprograms

Description

---------------------------------------------------------------------------- -- 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. -- -- ----------------------------------------------------------------------------

Any_Directory_Handle

type Any_Directory_Handle is access all Directory_Handle'Class;

Any_File_Handle

type Any_File_Handle is access all File_Handle'Class;

Any_Filesystem_Driver

type Any_Filesystem_Driver is access all Filesystem_Driver'Class;

Any_Node_Handle

type Any_Node_Handle is access all Node_Handle'Class;

Basename

function Basename (This : Node_Handle) return String
Parameters
This
Return Value

Close

procedure Close (This : in out Directory_Handle)

Closes the handle, and free the associated resources.

Parameters
This

Close

procedure Close (This : in out File_Handle)
Parameters
This

Close

procedure Close (This : in out Filesystem_Driver)
Parameters
This

Close

procedure Close (This : in out Node_Handle)
Parameters
This

Create_File

function Create_File (This : in out Filesystem_Driver;
                      Path : String)
                      return Status_Code
Parameters
This
Path
Return Value

Directory_Handle

type Directory_Handle is limited interface;

File_Handle

type File_Handle is limited interface;

File_Mode

type File_Mode is (Read_Only, Write_Only, Read_Write);
Enumeration Literal
Read_Only
Write_Only
Read_Write

File_Size

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.

Filesystem_Driver

type Filesystem_Driver is limited interface;

Flush

function Flush
  (This : in out File_Handle)
   return Status_Code
Parameters
This
Return Value

Get_FS

function Get_FS
  (This : Directory_Handle) return Any_Filesystem_Driver

Return the filesystem_Driver the handle belongs to.

Parameters
This
Return Value

Get_FS

function Get_FS
  (This : in out File_Handle) return Any_Filesystem_Driver
Parameters
This
Return Value

Get_FS

function Get_FS (This : Node_Handle) return Any_Filesystem_Driver
Parameters
This
Return Value

Is_Hidden

function Is_Hidden (This : Node_Handle) return Boolean
Parameters
This
Return Value

Is_Read_Only

function Is_Read_Only (This : Node_Handle) return Boolean
Parameters
This
Return Value

Is_Subdirectory

function Is_Subdirectory (This : Node_Handle) return Boolean
Parameters
This
Return Value

Is_Symlink

function Is_Symlink (This : Node_Handle) return Boolean
Parameters
This
Return Value

Mode

function Mode
  (This : File_Handle) return File_Mode
Parameters
This
Return Value

Node_Handle

type Node_Handle is interface;

Offset

function Offset
  (This : File_Handle)
   return File_Size
Parameters
This
Return Value

Open

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

Parameters
This
Path
Handle
Return Value

Open

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

Parameters
This
Path
Mode
Handle
Return Value

Open

function Open
  (This   : Node_Handle;
   Name   : String;
   Mode   : File_Mode;
   Handle : out Any_File_Handle)
   return Status_Code
Parameters
This
Name
Mode
Handle
Return Value

Read

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.

Parameters
This
Handle
Return Value

Read

function Read
  (This   : in out File_Handle;
   Addr   : System.Address;
   Length : in out File_Size)
   return Status_Code
Parameters
This
Addr
Length
Return Value

Remove_Directory

function Remove_Directory (This : in out Filesystem_Driver;
                           Path : String)
                           return Status_Code

Remove the directory located at Path in the This filesystem_Driver

Parameters
This
Path
Return Value

Reset

procedure Reset (This : in out Directory_Handle)

Resets the handle to the first node

Parameters
This

Root_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

Parameters
This
As
Handle
Return Value

Seek

function Seek
  (This   : in out File_Handle;
   Origin : Seek_Mode;
   Amount : in out File_Size)
   return Status_Code
Parameters
This
Origin
Amount
Return Value

Seek_Mode

type Seek_Mode is
  (
   From_Start,
   From_End,
   Forward,
   Backward);
Enumeration Literal
From_Start

Seek from the end of the file, backward

From_End

Seek from the current position, forward

Forward

Seek from the current position, backward

Backward

Size

function Size
  (This : File_Handle) return File_Size
Parameters
This
Return Value

Size

function Size (This : Node_Handle) return File_Size
Parameters
This
Return Value

Status_Code

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);
Enumeration Literal
OK
Non_Empty_Directory
Disk_Error

A hardware error occurred in the low level disk I/O

Disk_Full
Internal_Error
Drive_Not_Ready
No_Such_File
No_Such_Path
Not_Mounted

The mount point is invalid

Invalid_Name
Access_Denied
Already_Exists
Invalid_Object_Entry
Write_Protected
Invalid_Drive
No_Filesystem

The volume is not a FAT volume

Locked
Too_Many_Open_Files

All available handles are used

Invalid_Parameter
Input_Output_Error
No_MBR_Found
No_Partition_Found
No_More_Entries
Read_Only_File_System
Operation_Not_Permitted

Unlink

function Unlink (This : in out Filesystem_Driver;
                 Path : String)
                 return Status_Code

Remove the regular file located at Path in the This filesystem_Driver

Parameters
This
Path
Return Value

Write

function Write
  (This   : in out File_Handle;
   Addr   : System.Address;
   Length : File_Size)
   return Status_Code
Parameters
This
Addr
Length
Return Value