Skip to main content

Common Fluids Format 2024 R1

Storage

Last update: 16.07.2025
1#ifndef CFFSDK_PROJECT_STORAGE_H
2#define CFFSDK_PROJECT_STORAGE_H
3
4#include "Project/LibraryType.hpp"
5#include "Project/URL.hpp"
6#include "Project/Path.hpp"
7#include "Project/Error.hpp"
8#include <string>
9
10namespace ansys {
11namespace Project {
12
13class ANSYS_PROJECT_DLL Storage {
14public:
15 Storage(const std::string& pTypename);
16 virtual ~Storage();
17
18 // Virtual API
22 virtual Error createFolder(const URL& pParentPath,
23 const Path& pFolderPath) = 0;
27 virtual bool isFolder(const URL& pPath) = 0;
31 virtual bool isFile(const URL& pPath) = 0;
32
36 virtual Error copyFile(const std::string& pSource,const std::string& pTarget) = 0;
40 virtual Error getFileTimestamp(const URL& pFile,int& pTime) = 0;
44 virtual Error getFileChecksum(const URL& pFile,std::string& pChecksum) = 0;
48 virtual Error eraseFile(const URL& pFile) = 0;
49 enum EraseOptions { EraseFolderOnly, EraseFolderAndFiles, EraseRecursively };
55 virtual Error eraseFolder(const URL& pFile,EraseOptions pRecursive) = 0;
59 virtual Error moveFile(const URL& pSource,const URL& pTarget) = 0;
63 virtual Error matchFiles(const URL& pPath,std::string pWildcard,std::vector<URL>& pMatchFiles) = 0;
64
68 virtual std::string getFileCompressionSuffix() const = 0;
72 virtual Error compressFiles(const URL& pRootFolder,std::vector<URL>& pSourceFiles,const URL& pTargetArchive) = 0;
76 virtual Error extractFile(const URL& pArchive,const URL& pTargetLocation) = 0;
77
78 // Static API
79 static void registerInterface(const std::string& pType,
80 Storage* pInterface);
81 static Storage* getInterface(const std::string& pType);
82
83private:
84 std::string aTypename;
85};
86
87}
88}
89
90
91#endif // CFFSDK_PROJECT_STORAGE_H
The return state / error value of a Project function call.
Definition: Error.hpp:11
Paths used for internal Project filesystem.
Definition: Path.hpp:11
Base class for file storage management module.
Definition: Storage.hpp:13
virtual Error getFileChecksum(const URL &pFile, std::string &pChecksum)=0
Compute a checksum for the specified file.
virtual Error moveFile(const URL &pSource, const URL &pTarget)=0
Rename the file or folder.
virtual Error compressFiles(const URL &pRootFolder, std::vector< URL > &pSourceFiles, const URL &pTargetArchive)=0
Compress a list of files into a new zipped archive.
virtual Error createFolder(const URL &pParentPath, const Path &pFolderPath)=0
Create a folder in the specified URL, using the specified name.
virtual bool isFolder(const URL &pPath)=0
Indicates if a folder exists at the specified URL.
virtual Error matchFiles(const URL &pPath, std::string pWildcard, std::vector< URL > &pMatchFiles)=0
File query by wildcard pattern in the specified URL.
virtual bool isFile(const URL &pPath)=0
Indicates if a file exists at the specified URL.
virtual Error eraseFile(const URL &pFile)=0
Erase the file at the specified location.
virtual Error extractFile(const URL &pArchive, const URL &pTargetLocation)=0
Extract a zipped archive to the specified location.
virtual Error getFileTimestamp(const URL &pFile, int &pTime)=0
Compute a timestamp for the specified file.
virtual Error copyFile(const std::string &pSource, const std::string &pTarget)=0
Copy file from source to location, can be two different URL types.
virtual Error eraseFolder(const URL &pFile, EraseOptions pRecursive)=0
Erase the folder and content at the specified location.
virtual std::string getFileCompressionSuffix() const =0
Returns the required file suffix for compressFile API.
The address of a local or remote file, using the URI format.
Definition: URL.hpp:12
Definition: API.dox:1

Connect with Ansys