pub trait File_system_traits: Send + Sync {
Show 24 methods
// Required methods
fn Open(
&self,
Task: Task_identifier_type,
Path: &Path_type,
Flags: Flags_type,
Time: Time_type,
User: User_identifier_type,
Group: Group_identifier_type,
) -> Result_type<Local_file_identifier_type>;
fn Close(&self, File: Local_file_identifier_type) -> Result_type<()>;
fn Close_all(&self, Task: Task_identifier_type) -> Result_type<()>;
fn Duplicate(
&self,
File: Local_file_identifier_type,
) -> Result_type<Local_file_identifier_type>;
fn Transfert(
&self,
New_task: Task_identifier_type,
File: Local_file_identifier_type,
New_file: Option<File_identifier_type>,
) -> Result_type<Local_file_identifier_type>;
fn Remove(&self, Path: &Path_type) -> Result_type<()>;
fn Read(
&self,
File: Local_file_identifier_type,
Buffer: &mut [u8],
Time_type: Time_type,
) -> Result_type<Size_type>;
fn Write(
&self,
File: Local_file_identifier_type,
Buffer: &[u8],
Time_type: Time_type,
) -> Result_type<Size_type>;
fn Rename(
&self,
Source: &Path_type,
Destination: &Path_type,
) -> Result_type<()>;
fn Set_position(
&self,
File: Local_file_identifier_type,
Position: &Position_type,
) -> Result_type<Size_type>;
fn Flush(&self, File: Local_file_identifier_type) -> Result_type<()>;
fn Create_directory(
&self,
Path: &Path_type,
Time: Time_type,
User: User_identifier_type,
Group: Group_identifier_type,
) -> Result_type<()>;
fn Open_directory(
&self,
Path: &Path_type,
Task: Task_identifier_type,
) -> Result_type<Local_file_identifier_type>;
fn Read_directory(
&self,
File: Local_file_identifier_type,
) -> Result_type<Option<Entry_type>>;
fn Set_position_directory(
&self,
File: Local_file_identifier_type,
Position: Size_type,
) -> Result_type<()>;
fn Get_position_directory(
&self,
File: Local_file_identifier_type,
) -> Result_type<Size_type>;
fn Rewind_directory(
&self,
File: Local_file_identifier_type,
) -> Result_type<()>;
fn Close_directory(
&self,
File: Local_file_identifier_type,
) -> Result_type<()>;
fn Get_metadata(
&self,
File: Local_file_identifier_type,
) -> Result_type<Metadata_type>;
fn Set_metadata_from_path(
&self,
Path: &Path_type,
Metadata: &Metadata_type,
) -> Result_type<()>;
fn Get_metadata_from_path(
&self,
Path: &Path_type,
) -> Result_type<Metadata_type>;
fn Get_statistics(
&self,
File: Local_file_identifier_type,
) -> Result_type<Statistics_type>;
fn Get_mode(
&self,
File: Local_file_identifier_type,
) -> Result_type<Mode_type>;
// Provided method
fn Read_line(
&self,
File: Local_file_identifier_type,
Buffer: &mut String,
Time_type: Time_type,
) -> Result_type<Size_type> { ... }
}
Expand description
File system trait.
This allows to abstract the file system implementation.
The file system implementation should be registered in Virtual_file_system_type
.
The management of concurrent access to the file system is delegated to the implementation.
Thus, implementation should use a RwLock
or Mutex
to manage concurrency.
Required Methods§
Sourcefn Open(
&self,
Task: Task_identifier_type,
Path: &Path_type,
Flags: Flags_type,
Time: Time_type,
User: User_identifier_type,
Group: Group_identifier_type,
) -> Result_type<Local_file_identifier_type>
fn Open( &self, Task: Task_identifier_type, Path: &Path_type, Flags: Flags_type, Time: Time_type, User: User_identifier_type, Group: Group_identifier_type, ) -> Result_type<Local_file_identifier_type>
Open a file.
§Arguments
Task
: Task identifier, used to identify the task since the file identifier is unique to the task.Path
: Path to the file.Flags
: Flags to open the file.File_identifier
: Optional file identifier, if not provided, a new file identifier is generated, otherwise, the provided file identifier is used.
§Errors
Returns an error if the file doesn’t exists. Returns an error if the user / group doesn’t have the permission to open the file (mode is not compatible with the file permissions). Return an error if the provided file identifier is already used by the task.
Sourcefn Close(&self, File: Local_file_identifier_type) -> Result_type<()>
fn Close(&self, File: Local_file_identifier_type) -> Result_type<()>
Close a file.
§Errors
Returns an error if the file is not opened by the task (invalid file identifier). Returns an error if the task identifier is invalid.
Sourcefn Close_all(&self, Task: Task_identifier_type) -> Result_type<()>
fn Close_all(&self, Task: Task_identifier_type) -> Result_type<()>
Close all files opened by the task.
Sourcefn Duplicate(
&self,
File: Local_file_identifier_type,
) -> Result_type<Local_file_identifier_type>
fn Duplicate( &self, File: Local_file_identifier_type, ) -> Result_type<Local_file_identifier_type>
Duplicate a file identifier.
Sourcefn Transfert(
&self,
New_task: Task_identifier_type,
File: Local_file_identifier_type,
New_file: Option<File_identifier_type>,
) -> Result_type<Local_file_identifier_type>
fn Transfert( &self, New_task: Task_identifier_type, File: Local_file_identifier_type, New_file: Option<File_identifier_type>, ) -> Result_type<Local_file_identifier_type>
Transfer a file identifier from a task to another.
Sourcefn Remove(&self, Path: &Path_type) -> Result_type<()>
fn Remove(&self, Path: &Path_type) -> Result_type<()>
Remove a file or a directory.
§Errors
Returns an error if the file doesn’t exists. Returns an error if the user / group doesn’t have the permission to delete the file (no write permission on parent directory).
Sourcefn Read(
&self,
File: Local_file_identifier_type,
Buffer: &mut [u8],
Time_type: Time_type,
) -> Result_type<Size_type>
fn Read( &self, File: Local_file_identifier_type, Buffer: &mut [u8], Time_type: Time_type, ) -> Result_type<Size_type>
Sourcefn Write(
&self,
File: Local_file_identifier_type,
Buffer: &[u8],
Time_type: Time_type,
) -> Result_type<Size_type>
fn Write( &self, File: Local_file_identifier_type, Buffer: &[u8], Time_type: Time_type, ) -> Result_type<Size_type>
Write a file.
§Errors
- If the file is not opened (invalid file identifier).
- If the file is not opened in write mode (invalid mode).