Skip to content

PackageFileSystem

A FileSystem implementation that provides access to an Amplitude package file.

Inherits the following classes: SparkyStudios::Audio::Amplitude::FileSystem

Public Functions

Type Name
virtual bool Exists (const AmOsString & path) override const
Checks if an item (file or folder) exists on the file system.
virtual const AmOsString & GetBasePath () override const
Returns the base path of the file system.
virtual bool IsDirectory (const AmOsString & path) override const
Checks if an item (file or folder) is a directory.
bool IsValid () const
Returns if the package file is valid and loaded.
virtual AmOsString Join (const std::vector< AmOsString > & parts) override const
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) override const
Opens the file at the given path.
PackageFileSystem ()
Constructs a new PackageFileSystem instance.
virtual AmOsString ResolvePath (const AmOsString & path) override const
Resolves a relative path from the file system base path.
virtual void SetBasePath (const AmOsString & basePath) override
Changes the file system base path.
void SetPlatformFileSystem (Args &&... args)
Sets the platform file system to use for opening and reading the package file.
void SetPlatformFileSystem (std::shared_ptr< FileSystem > fileSystem)
Sets the platform file system to use for opening and reading the package file.
virtual void StartCloseFileSystem () override
Stops the FileSystem .
virtual void StartOpenFileSystem () override
Opens the FileSystem .
virtual bool TryFinalizeCloseFileSystem () override
Checks if the FileSystem is stopped.
virtual bool TryFinalizeOpenFileSystem () override
Checks if the FileSystem is loaded.
~PackageFileSystem () override
Destroys the PackageFileSystem instance.

Public Functions inherited from SparkyStudios::Audio::Amplitude::FileSystem

See SparkyStudios::Audio::Amplitude::FileSystem

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::PackageFileSystem::Exists (
    const AmOsString & path
) override const

Parameters:

  • path The path to the item.

Returns:

true if the file exists, false otherwise.

Implements SparkyStudios::Audio::Amplitude::FileSystem::Exists

GetBasePath

Returns the base path of the file system.

virtual const AmOsString & Amplitude::PackageFileSystem::GetBasePath () override const

Returns:

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

Implements SparkyStudios::Audio::Amplitude::FileSystem::GetBasePath

IsDirectory

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

virtual bool Amplitude::PackageFileSystem::IsDirectory (
    const AmOsString & path
) override const

Parameters:

  • path The path to the item.

Returns:

true if the file is a directory, false otherwise.

Implements SparkyStudios::Audio::Amplitude::FileSystem::IsDirectory

IsValid

Returns if the package file is valid and loaded.

bool Amplitude::PackageFileSystem::IsValid () const

Returns:

true if the package file is valid and loaded, 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::PackageFileSystem::Join (
    const std::vector< AmOsString > & parts
) override const

Parameters:

  • parts The parts of the path.

Returns:

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

Implements SparkyStudios::Audio::Amplitude::FileSystem::Join

OpenFile

Opens the file at the given path.

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

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::OpenFile

PackageFileSystem

Constructs a new PackageFileSystem instance.

Amplitude::PackageFileSystem::PackageFileSystem () 
ResolvePath

Resolves a relative path from the file system base path.

virtual AmOsString Amplitude::PackageFileSystem::ResolvePath (
    const AmOsString & path
) override const

Returns:

The resolved path.

Implements SparkyStudios::Audio::Amplitude::FileSystem::ResolvePath

SetBasePath

Changes the file system base path.

virtual void Amplitude::PackageFileSystem::SetBasePath (
    const AmOsString & basePath
) override

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::SetBasePath

SetPlatformFileSystem[1/2]

Sets the platform file system to use for opening and reading the package file.

template<class TFileSystem, class... Args>
inline void Amplitude::PackageFileSystem::SetPlatformFileSystem (
    Args &&... args
) 

Parameters:

  • args The parameters to pass to the file system constructor.
SetPlatformFileSystem[2/2]

Sets the platform file system to use for opening and reading the package file.

void Amplitude::PackageFileSystem::SetPlatformFileSystem (
    std::shared_ptr< FileSystem > fileSystem
) 

Parameters:

  • fileSystem The file system to use.
StartCloseFileSystem

Stops the FileSystem .

virtual void Amplitude::PackageFileSystem::StartCloseFileSystem () override

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::StartCloseFileSystem

StartOpenFileSystem

Opens the FileSystem .

virtual void Amplitude::PackageFileSystem::StartOpenFileSystem () override

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::StartOpenFileSystem

TryFinalizeCloseFileSystem

Checks if the FileSystem is stopped.

virtual bool Amplitude::PackageFileSystem::TryFinalizeCloseFileSystem () override

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::TryFinalizeCloseFileSystem

TryFinalizeOpenFileSystem

Checks if the FileSystem is loaded.

virtual bool Amplitude::PackageFileSystem::TryFinalizeOpenFileSystem () override

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.

Implements SparkyStudios::Audio::Amplitude::FileSystem::TryFinalizeOpenFileSystem

~PackageFileSystem

Destroys the PackageFileSystem instance.

Amplitude::PackageFileSystem::~PackageFileSystem () override

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