Skip to main content

Common Fluids Format 2025 R1

ansys::Project::Storage Class Reference

Last update: 19.05.2025

Base class for file storage management module. More...

#include "Storage.hpp"

Inheritance diagram for ansys::Project::Storage:
ansys::Project::StorageFilesystem

Public Types

enum  EraseOptions { EraseFolderOnly , EraseFolderAndFiles , EraseRecursively }
 

Public Member Functions

 Storage (const std::string &pTypename)
 Constructor. More...
 
virtual ~Storage ()
 Destructor. More...
 
virtual Error createFolder (const URL &pParentPath, const Path &pFolderPath)=0
 Create a folder in the specified URL, using the specified name. More...
 
virtual bool isFolder (const URL &pPath)=0
 Indicates if a folder exists at the specified URL. More...
 
virtual bool isFile (const URL &pPath)=0
 Indicates if a file exists at the specified URL. More...
 
virtual Error copyFile (const std::string &pSource, const std::string &pTarget)=0
 Copy file from source to location, can be two different URL types. More...
 
virtual Error getFileTimestamp (const URL &pFile, int &pTime)=0
 Compute a timestamp for the specified file. More...
 
virtual Error getFileChecksum (const URL &pFile, std::string &pChecksum)=0
 Compute a checksum for the specified file. More...
 
virtual Error eraseFile (const URL &pFile)=0
 Erase the file at the specified location. More...
 
virtual Error eraseFolder (const URL &pFile, EraseOptions pRecursive)=0
 Erase the folder and content at the specified location. More...
 
virtual Error moveFile (const URL &pSource, const URL &pTarget)=0
 Rename the file or folder. More...
 
virtual Error matchFiles (const URL &pPath, std::string pWildcard, std::vector< URL > &pMatchFiles)=0
 File query by wildcard pattern in the specified URL. More...
 
virtual std::string getFileCompressionSuffix () const =0
 Returns the required file suffix for compressFile API. More...
 
virtual Error compressFiles (const URL &pRootFolder, std::vector< URL > &pSourceFiles, const URL &pTargetArchive)=0
 Compress a list of files into a new zipped archive. More...
 
virtual Error extractFile (const URL &pArchive, const URL &pTargetLocation)=0
 Extract a zipped archive to the specified location. More...
 

Static Public Member Functions

static void registerInterface (const std::string &pType, Storage *pInterface)
 Register a Storage object to work with a specific URL type. More...
 
static StoragegetInterface (const std::string &pType)
 Retrieve the Storage object to use with a specific URL type. More...
 

Detailed Description

Base class for file storage management module.

The Project framework only access files on disk through the Storage interface, StorageFilesystem is used to access local files ( URL with no type, or of type file:// ). Additional storage frameworks can be defined, and bound to URL types. See registerInterface()

Member Enumeration Documentation

◆ EraseOptions

Enumerator
EraseFolderOnly 
EraseFolderAndFiles 
EraseRecursively 

Constructor & Destructor Documentation

◆ Storage()

ansys::Project::Storage::Storage ( const std::string &  pTypename)

Constructor.

Parameters
pTypenameType of URL handled by this Storage

◆ ~Storage()

ansys::Project::Storage::~Storage ( )
virtual

Destructor.

Member Function Documentation

◆ compressFiles()

virtual Error ansys::Project::Storage::compressFiles ( const URL pRootFolder,
std::vector< URL > &  pSourceFiles,
const URL pTargetArchive 
)
pure virtual

Compress a list of files into a new zipped archive.

Implemented in ansys::Project::StorageFilesystem.

◆ copyFile()

virtual Error ansys::Project::Storage::copyFile ( const std::string &  pSource,
const std::string &  pTarget 
)
pure virtual

Copy file from source to location, can be two different URL types.

Implemented in ansys::Project::StorageFilesystem.

◆ createFolder()

virtual Error ansys::Project::Storage::createFolder ( const URL pParentPath,
const Path pFolderPath 
)
pure virtual

Create a folder in the specified URL, using the specified name.

Implemented in ansys::Project::StorageFilesystem.

◆ eraseFile()

virtual Error ansys::Project::Storage::eraseFile ( const URL pFile)
pure virtual

Erase the file at the specified location.

Implemented in ansys::Project::StorageFilesystem.

◆ eraseFolder()

virtual Error ansys::Project::Storage::eraseFolder ( const URL pFile,
EraseOptions  pRecursive 
)
pure virtual

Erase the folder and content at the specified location.

Parameters
pRecursiveIndicate if should erase folder only (assumed empty), folder and its files, or folder and any number of subfolders.

Implemented in ansys::Project::StorageFilesystem.

◆ extractFile()

virtual Error ansys::Project::Storage::extractFile ( const URL pArchive,
const URL pTargetLocation 
)
pure virtual

Extract a zipped archive to the specified location.

Implemented in ansys::Project::StorageFilesystem.

◆ getFileChecksum()

virtual Error ansys::Project::Storage::getFileChecksum ( const URL pFile,
std::string &  pChecksum 
)
pure virtual

Compute a checksum for the specified file.

Implemented in ansys::Project::StorageFilesystem.

◆ getFileCompressionSuffix()

virtual std::string ansys::Project::Storage::getFileCompressionSuffix ( ) const
pure virtual

Returns the required file suffix for compressFile API.

Implemented in ansys::Project::StorageFilesystem.

◆ getFileTimestamp()

virtual Error ansys::Project::Storage::getFileTimestamp ( const URL pFile,
int &  pTime 
)
pure virtual

Compute a timestamp for the specified file.

Implemented in ansys::Project::StorageFilesystem.

◆ getInterface()

Storage * ansys::Project::Storage::getInterface ( const std::string &  pType)
static

Retrieve the Storage object to use with a specific URL type.

◆ isFile()

virtual bool ansys::Project::Storage::isFile ( const URL pPath)
pure virtual

Indicates if a file exists at the specified URL.

Implemented in ansys::Project::StorageFilesystem.

◆ isFolder()

virtual bool ansys::Project::Storage::isFolder ( const URL pPath)
pure virtual

Indicates if a folder exists at the specified URL.

Implemented in ansys::Project::StorageFilesystem.

◆ matchFiles()

virtual Error ansys::Project::Storage::matchFiles ( const URL pPath,
std::string  pWildcard,
std::vector< URL > &  pMatchFiles 
)
pure virtual

File query by wildcard pattern in the specified URL.

Implemented in ansys::Project::StorageFilesystem.

◆ moveFile()

virtual Error ansys::Project::Storage::moveFile ( const URL pSource,
const URL pTarget 
)
pure virtual

Rename the file or folder.

Implemented in ansys::Project::StorageFilesystem.

◆ registerInterface()

void ansys::Project::Storage::registerInterface ( const std::string &  pType,
Storage pInterface 
)
static

Register a Storage object to work with a specific URL type.

Connect with Ansys