Skip to content

NSFileSystem

An implementation of the FileSystem interface for iOS using NSFileManager.

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

Detailed Description

This class provides file system operations for iOS using the NSFileManager API.

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.
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.
NSFileSystem ()
Constructs a new NSFileSystem instance.
virtual std::shared_ptr< File > OpenFile (const AmOsString & path, eFileOpenMode mode=eFileOpenMode_Read) override const
Opens the file at the given path.
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.
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.
~NSFileSystem () override
Destroys the NSFileSystem 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::NSFileSystem::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::NSFileSystem::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::NSFileSystem::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

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::NSFileSystem::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

NSFileSystem

Constructs a new NSFileSystem instance.

Amplitude::NSFileSystem::NSFileSystem () 
OpenFile

Opens the file at the given path.

virtual std::shared_ptr< File > Amplitude::NSFileSystem::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

ResolvePath

Resolves a relative path from the file system base path.

virtual AmOsString Amplitude::NSFileSystem::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::NSFileSystem::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

StartCloseFileSystem

Stops the FileSystem .

virtual void Amplitude::NSFileSystem::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::NSFileSystem::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::NSFileSystem::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::NSFileSystem::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

~NSFileSystem

Destroys the NSFileSystem instance.

Amplitude::NSFileSystem::~NSFileSystem () override

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