WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
Public Member Functions | List of all members
wrench::LogicalFileSystem Class Reference

A class that implements a weak file system abstraction. More...

#include <LogicalFileSystem.h>

Public Member Functions

 LogicalFileSystem (std::string hostname, StorageService *storage_service, std::string mount_point)
 Constructor. More...
 
void createDirectory (std::string absolute_path)
 Create a new directory. More...
 
bool doesDirectoryExist (std::string absolute_path)
 Checks whether a directory exists. More...
 
double getFreeSpace ()
 Get the file system's free space. More...
 
double getTotalCapacity ()
 Get the total capacity. More...
 
bool hasEnoughFreeSpace (double bytes)
 Checks whether there is enough space to store some number of bytes. More...
 
void init ()
 Initializes the Logical File System (must be called before any other operation on this file system)
 
bool isDirectoryEmpty (std::string absolute_path)
 Checks whether a directory is empty. More...
 
bool isFileInDirectory (std::shared_ptr< DataFile >file, std::string absolute_path)
 Checks whether a file is in a directory. More...
 
std::set< std::shared_ptr< DataFile > > listFilesInDirectory (std::string absolute_path)
 Get the files in a directory as a set. More...
 
void removeAllFilesInDirectory (std::string absolute_path)
 Remove all files in a directory. More...
 
void removeEmptyDirectory (std::string absolute_path)
 Remove an empty directory. More...
 
void removeFileFromDirectory (std::shared_ptr< DataFile >file, std::string absolute_path)
 Remove a file in a directory. More...
 
void reserveSpace (std::shared_ptr< DataFile >file, std::string absolute_path)
 Reserve space for a file that will be stored. More...
 
void storeFileInDirectory (std::shared_ptr< DataFile >file, std::string absolute_path)
 Store file in directory. More...
 
void unreserveSpace (std::shared_ptr< DataFile >file, std::string absolute_path)
 Unreserve space that was saved for a file (likely a failed transfer) More...
 

Detailed Description

A class that implements a weak file system abstraction.

Constructor & Destructor Documentation

◆ LogicalFileSystem()

wrench::LogicalFileSystem::LogicalFileSystem ( std::string  hostname,
StorageService storage_service,
std::string  mount_point 
)
explicit

Constructor.

Parameters
hostnamethe host on which the file system is located
storage_servicethe storage service this file system is for
mount_pointthe mount point

Member Function Documentation

◆ createDirectory()

void wrench::LogicalFileSystem::createDirectory ( std::string  absolute_path)

Create a new directory.

Parameters
absolute_paththe directory's absolute path
Exceptions
std::invalid_argument

◆ doesDirectoryExist()

bool wrench::LogicalFileSystem::doesDirectoryExist ( std::string  absolute_path)

Checks whether a directory exists.

Parameters
absolute_paththe directory's absolute path
Returns
true if the directory exists

◆ getFreeSpace()

double wrench::LogicalFileSystem::getFreeSpace ( )

Get the file system's free space.

Returns
the free space in bytes

◆ getTotalCapacity()

double wrench::LogicalFileSystem::getTotalCapacity ( )

Get the total capacity.

Returns
the total capacity

◆ hasEnoughFreeSpace()

bool wrench::LogicalFileSystem::hasEnoughFreeSpace ( double  bytes)

Checks whether there is enough space to store some number of bytes.

Parameters
bytesa number of bytes
Returns
true if the number of bytes can fit

◆ isDirectoryEmpty()

bool wrench::LogicalFileSystem::isDirectoryEmpty ( std::string  absolute_path)

Checks whether a directory is empty.

Parameters
absolute_paththe directory's absolute path
Returns
true if the directory is empty
Exceptions
std::invalid_argument

◆ isFileInDirectory()

bool wrench::LogicalFileSystem::isFileInDirectory ( std::shared_ptr< DataFile file,
std::string  absolute_path 
)

Checks whether a file is in a directory.

Parameters
filethe file
absolute_paththe directory's absolute path
Returns
true if the file is present
Exceptions
std::invalid_argument

◆ listFilesInDirectory()

std::set< std::shared_ptr< DataFile > > wrench::LogicalFileSystem::listFilesInDirectory ( std::string  absolute_path)

Get the files in a directory as a set.

Parameters
absolute_paththe directory's absolute path
Returns
a set of files
Exceptions
std::invalid_argument

◆ removeAllFilesInDirectory()

void wrench::LogicalFileSystem::removeAllFilesInDirectory ( std::string  absolute_path)

Remove all files in a directory.

Parameters
absolute_paththe directory's absolute path
Exceptions
std::invalid_argument

◆ removeEmptyDirectory()

void wrench::LogicalFileSystem::removeEmptyDirectory ( std::string  absolute_path)

Remove an empty directory.

Parameters
absolute_paththe directory's absolute path
Exceptions
std::invalid_argument

◆ removeFileFromDirectory()

void wrench::LogicalFileSystem::removeFileFromDirectory ( std::shared_ptr< DataFile file,
std::string  absolute_path 
)

Remove a file in a directory.

Parameters
filethe file to remove
absolute_paththe directory's absolute path
Exceptions
std::invalid_argument

◆ reserveSpace()

void wrench::LogicalFileSystem::reserveSpace ( std::shared_ptr< DataFile file,
std::string  absolute_path 
)

Reserve space for a file that will be stored.

Parameters
filethe file
absolute_paththe path where it will be written
Exceptions
std::invalid_argument

◆ storeFileInDirectory()

void wrench::LogicalFileSystem::storeFileInDirectory ( std::shared_ptr< DataFile file,
std::string  absolute_path 
)

Store file in directory.

Parameters
filethe file to store
absolute_paththe directory's absolute path (at the mount point)
Exceptions
std::invalid_argument

◆ unreserveSpace()

void wrench::LogicalFileSystem::unreserveSpace ( std::shared_ptr< DataFile file,
std::string  absolute_path 
)

Unreserve space that was saved for a file (likely a failed transfer)

Parameters
filethe file
absolute_paththe path where it would have been written
Exceptions
std::invalid_argument

The documentation for this class was generated from the following files: