# MemoryDevice

## Content

class | MemoryFilesystem

## Functions

bool | `Exists`
bool | `IsDirectory`
bool | `CreateDirs`
bool | `RemoveAll`
MemoryDeviceFile | `OpenFileForReading`
char const * | `ToAbsolutePath`

## Detailed Description

class MemoryDevice

  The MemoryDevice class is an in-memory virtual file device used to sandbox file IO. These objects can be obtained by Database::GetMemoryDevice.

  Public Functions

  bool Exists(char const *utf8_path)

    Queries if a path exists within this device.

    Returns

      True if the path exists and false otherwise.

  bool IsDirectory(char const *utf8_path)

    Queries if a path is a directory within this device.

    Returns

      True if the path is a directory and false otherwise.

  bool CreateDirs(char const *utf8_directory_path)

    Creates all the directories in this device required for the input directory path to exist.

    Returns

      True if the leaf directory was successfully created and false otherwise.

  bool RemoveAll(char const *utf8_path)

    Removes a file or directory in this device. If it is a directory, all of its children are also removed.

    Returns

      True if the directory was successfully removed and false otherwise.

  MemoryDeviceFile OpenFileForReading(char const *utf8_path)

    Opens the file specified by `path` for read operations. A valid MemoryDeviceFile will be returned which allows reading the file data.

    If the path is not a valid file, an Exception will be thrown.

    Returns

      A valid file object if the given path is an actual file.

  char const *ToAbsolutePath(char const *utf8_path)

    Transforms the given path into an absolute version of the same underlying path. To find the current working directory for the MemoryDevice, call this function with an empty string for the path.

    Returns

      An aboslute version of the given path.

  Friends

  friend class ::TC::IO::MemoryFilesystem