Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::FileSystem Class Reference

File system object. More...

Inheritance diagram for gem::FileSystem:
Collaboration diagram for gem::FileSystem:

Public Member Functions

 FileSystem (const FileSystem &)=delete
 FileSystem (FileSystem &&filesystem)=default
 Default move constructor noexcept is deduced.
FileSystem & operator= (const FileSystem &)=delete
FileSystem & operator= (FileSystem &&filesystem)=default
 Default move assignment noexcept is deduced.
FileSystemFolder scan (const String &path, const String &fileTemplate, const String &folderTemplate, bool recursive=false) const noexcept
 Scan folder for all file system items.
FileSystemFolder scan (const String &path, const String &fileTemplate) const noexcept
 Scan folder for all files.
const FileSystemFolderscanMore (const String &path, const String &fileTemplate, const String &folderTemplate, FileSystemFolder &folder, bool recursive=false) const noexcept
 Scan folder for all file system items and append to existing result.
const FileSystemFolderscanMore (const String &path, const String &fileTemplate, FileSystemFolder &folder) const noexcept
 Scan folder for all files and append to existing result.
String getLastComponent (const String &path) const noexcept
 extract last path component ( file or folder )
String getFileName (const String &path) const noexcept
 extract last path component file name
String getFileExt (const String &path) const noexcept
 extract last path component file extension
String removeLastComponent (const String &path) const noexcept
 remove last path component ( file or folder )
template<typename ... Components>
String makePath (Components &&... components)
 make path from components
int createFolder (const String &path, bool createAllComponents) const noexcept
 Create a folder identified by path.
int deleteFile (const String &path) const noexcept
 Delete the file specified by path.
int copyFile (const String &source, const String &destination, bool overwrite=false) const noexcept
 Copy the source file to destination location.
int moveFile (const String &source, const String &destination, bool overwrite=false) const noexcept
 Move the source file to destination location.
int deleteAllFiles (const String &folder, const String &filesTemplate) const noexcept
 Delete all files in the given folder.
int uncompress (const String &archivePath, const String &folder) const noexcept
 Uncompress the given archive to the given folder.

Detailed Description

File system object.

Implements share-read / write Api object over IFileSystem.

This behaves like a singleton, i.e. all instances are sharing behind the same API interface

Constructor & Destructor Documentation

◆ FileSystem()

gem::FileSystem::FileSystem ( FileSystem && filesystem)
default

Default move constructor noexcept is deduced.

Parameters
filesystemThe source object

Member Function Documentation

◆ copyFile()

int gem::FileSystem::copyFile ( const String & source,
const String & destination,
bool overwrite = false ) const
inlinenoexcept

Copy the source file to destination location.

Parameters
[in]sourceSource file path
[in]destinationDestination location. If last char in the destination path is a path separator, the file name is from source is appended
[in]overwriteOverwrite destination file if exists
Returns
Error code

◆ createFolder()

int gem::FileSystem::createFolder ( const String & path,
bool createAllComponents ) const
inlinenoexcept

Create a folder identified by path.

Parameters
[in]pathFolder path including folder name
[in]createAllComponentsCreate all path components ( if doesn't exist )
Returns
Error code

◆ deleteAllFiles()

int gem::FileSystem::deleteAllFiles ( const String & folder,
const String & filesTemplate ) const
inlinenoexcept

Delete all files in the given folder.

Parameters
[in]folderThe target folder path
[in]filesTemplateThe template of the files to be deleted. *, ? and [] wildcards are supported
Returns
Error code

◆ deleteFile()

int gem::FileSystem::deleteFile ( const String & path) const
inlinenoexcept

Delete the file specified by path.

Parameters
[in]pathFile path
Returns
Error code

◆ getFileExt()

String gem::FileSystem::getFileExt ( const String & path) const
inlinenoexcept

extract last path component file extension

Parameters
[in]pathFile path
Returns
The file ext as string

◆ getFileName()

String gem::FileSystem::getFileName ( const String & path) const
inlinenoexcept

extract last path component file name

Parameters
[in]pathFile path
Returns
The file name as string

◆ getLastComponent()

String gem::FileSystem::getLastComponent ( const String & path) const
inlinenoexcept

extract last path component ( file or folder )

Parameters
[in]pathFile or folder path
Returns
The path component as string

◆ makePath()

template<typename ... Components>
String gem::FileSystem::makePath ( Components &&... components)
inline

make path from components

Parameters
[in]componentsThe components of the path.
Returns
The resulted path as String.

◆ moveFile()

int gem::FileSystem::moveFile ( const String & source,
const String & destination,
bool overwrite = false ) const
inlinenoexcept

Move the source file to destination location.

Parameters
[in]sourceSource file path
[in]destinationDestination location. If last char in the destination path is a path separator, the file name is from source is appended
[in]overwriteOverwrite destination file if exists
Returns
Error code

◆ operator=()

FileSystem & gem::FileSystem::operator= ( FileSystem && filesystem)
default

Default move assignment noexcept is deduced.

Parameters
filesystemThe source object
Returns
The target object

◆ removeLastComponent()

String gem::FileSystem::removeLastComponent ( const String & path) const
inlinenoexcept

remove last path component ( file or folder )

Parameters
[in]pathFile or folder path
Returns
The remaining path as string

◆ scan() [1/2]

FileSystemFolder gem::FileSystem::scan ( const String & path,
const String & fileTemplate ) const
inlinenoexcept

Scan folder for all files.

Parameters
[in]pathPath to target folder
[in]fileTemplateFile name template to match

Use "*" for any file, use empty string to not scan for files

Returns
The folder structure

◆ scan() [2/2]

FileSystemFolder gem::FileSystem::scan ( const String & path,
const String & fileTemplate,
const String & folderTemplate,
bool recursive = false ) const
inlinenoexcept

Scan folder for all file system items.

Parameters
[in]pathPath to target folder
[in]fileTemplateFile name template to match

Use "*" for any file, use empty string to not scan for files

Parameters
[in]folderTemplateSub-folders name template to match

Use "*" for any folder, use empty string to not scan for folders

Parameters
[in]recursiveScan recursively on sub-folders flag
Returns
The folder structure

◆ scanMore() [1/2]

const FileSystemFolder & gem::FileSystem::scanMore ( const String & path,
const String & fileTemplate,
const String & folderTemplate,
FileSystemFolder & folder,
bool recursive = false ) const
inlinenoexcept

Scan folder for all file system items and append to existing result.

Parameters
[in]pathPath to target folder
[in]fileTemplateFile name template to match

Use "*" for any file, use empty string to not scan for files

Parameters
[in]folderTemplateSub-folders name template to match

Use "*" for any folder, use empty string to not scan for folders

Parameters
[in]folderThe existing folder result
[in]recursiveScan recursively on sub-folders flag
Returns
The folder structure

◆ scanMore() [2/2]

const FileSystemFolder & gem::FileSystem::scanMore ( const String & path,
const String & fileTemplate,
FileSystemFolder & folder ) const
inlinenoexcept

Scan folder for all files and append to existing result.

Parameters
[in]pathPath to target folder
[in]fileTemplateFile name template to match

Use "*" for any file, use empty string to not scan for files

Parameters
[in]folderThe existing folder result
Returns
The folder structure

◆ uncompress()

int gem::FileSystem::uncompress ( const String & archivePath,
const String & folder ) const
inlinenoexcept

Uncompress the given archive to the given folder.

Parameters
[in]archivePathThe absolute path to archive
[in]folderThe absolute path to destination folder
Returns
Error code