Skip to content

FileSystem

Base class for files and resources loaders.

Inherited by the following classes: SparkyStudios::Audio::Amplitude::AssetManagerFileSystem, SparkyStudios::Audio::Amplitude::DiskFileSystem, SparkyStudios::Audio::Amplitude::NSFileSystem, SparkyStudios::Audio::Amplitude::PackageFileSystem

Detailed Description

The engine uses this FileSystem class as an interface to load files and other resources. It provides basic functionalities needed by a file system.

You are able to implement your own FileSystem subclass to fit your needs, for example, reading files from a network drive or a custom storage system.

Public Functions

Type Name
virtual bool Exists (const AmOsString & path) const = 0
Checks if an item (file or folder) exists on the file system.
virtual const AmOsString & GetBasePath () const = 0
Returns the base path of the file system.
virtual bool IsDirectory (const AmOsString & path) const = 0
Checks if an item (file or folder) is a directory.
virtual AmOsString Join (const std::vector< AmOsString > & parts) const = 0
Merge the given parts of the path into a single path by joining them with the file system's path separator.
virtual std::shared_ptr< File > OpenFile (const AmOsString & path, eFileOpenMode mode=eFileOpenMode_Read) const = 0
Opens the file at the given path.
virtual AmOsString ResolvePath (const AmOsString & path) const = 0
Resolves a relative path from the file system base path.
virtual void SetBasePath (const AmOsString & basePath) = 0
Changes the file system base path.
virtual void StartCloseFileSystem () = 0
Stops the FileSystem .
virtual void StartOpenFileSystem () = 0
Opens the FileSystem .
virtual bool TryFinalizeCloseFileSystem () = 0
Checks if the FileSystem is stopped.
virtual bool TryFinalizeOpenFileSystem () = 0
Checks if the FileSystem is loaded.
virtual ~FileSystem () = default
Default destructor.

Public Functions Documentation

Exists

Checks if an item (file or folder) exists on the file system.

virtual bool Amplitude::FileSystem::Exists (
    const AmOsString & path
) const = 0

Parameters:

  • path The path to the item.

Returns:

true if the file exists, false otherwise.

GetBasePath

Returns the base path of the file system.

virtual const AmOsString & Amplitude::FileSystem::GetBasePath () const = 0

Returns:

The base path for resolving relative paths from which the engine will load resources.

IsDirectory

Checks if an item (file or folder) is a directory.

virtual bool Amplitude::FileSystem::IsDirectory (
    const AmOsString & path
) const = 0

Parameters:

  • path The path to the item.

Returns:

true if the file is a directory, false otherwise.

Join

Merge the given parts of the path into a single path by joining them with the file system's path separator.

virtual AmOsString Amplitude::FileSystem::Join (
    const std::vector< AmOsString > & parts
) const = 0

Parameters:

  • parts The parts of the path.

Returns:

A path concatenated with the given parts and the file system path separator.

OpenFile

Opens the file at the given path.

virtual std::shared_ptr< File > Amplitude::FileSystem::OpenFile (
    const AmOsString & path,
    eFileOpenMode mode=eFileOpenMode_Read
) const = 0

Parameters:

  • path The path to the file to open.
  • mode The file open mode.

Returns:

The opened file. The returned File implementation depends on the FileSystem implementation.

ResolvePath

Resolves a relative path from the file system base path.

virtual AmOsString Amplitude::FileSystem::ResolvePath (
    const AmOsString & path
) const = 0

Returns:

The resolved path.

SetBasePath

Changes the file system base path.

virtual void Amplitude::FileSystem::SetBasePath (
    const AmOsString & basePath
) = 0

That path is interpreted by the implementation and doesn't necessarily have to be a real path on disk. It's just used as the base path for resolving relative paths from which the engine will load resources.

Parameters:

  • basePath The file system base path.
StartCloseFileSystem

Stops the FileSystem .

virtual void Amplitude::FileSystem::StartCloseFileSystem () = 0

This function MUST be called when the FileSystem is no longer needed. It is used to stop the file system (e.g.: unmounting an archive).

Note:

  • For implementations, it is recommended to process the stopping in a separate thread.
  • The implementation is free to ignore this if not needed.
StartOpenFileSystem

Opens the FileSystem .

virtual void Amplitude::FileSystem::StartOpenFileSystem () = 0

This function MUST be called before any other actions in the file system. It is used to initialize the file system (e.g.: mounting an archive).

Note:

  • For implementations, It is recommended to process the initialization in a separate thread. *
  • The implementation is free to ignore this if not needed.
TryFinalizeCloseFileSystem

Checks if the FileSystem is stopped.

virtual bool Amplitude::FileSystem::TryFinalizeCloseFileSystem () = 0

Since the StartCloseFileSystem() function is designed to be asynchronous, this function is used to check if the FileSystem has been successfully stopped.

Returns:

true if the FileSystem has been fully stopped, false otherwise.

TryFinalizeOpenFileSystem

Checks if the FileSystem is loaded.

virtual bool Amplitude::FileSystem::TryFinalizeOpenFileSystem () = 0

Since the StartOpenFileSystem() function is designed to be asynchronous, this function is used to check if the FileSystem has been successfully initialized.

Returns:

true if the FileSystem has been fully loaded, false otherwise.

~FileSystem

Default destructor.

virtual Amplitude::FileSystem::~FileSystem () = default

The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/IO/FileSystem.h