#include <File.hpp>
|
| enum class | CreateMode : uint32_t {
eUserRead = 0x00000001
, eUserWrite = 0x00000002
, eUserExec = 0x00000004
, eGroupRead = 0x00000010
,
eGroupWrite = 0x00000020
, eGroupExec = 0x00000040
, eOthersRead = 0x00000100
, eOthersWrite = 0x00000200
,
eOthersExec = 0x00000400
, eUserRWX = eUserRead | eUserWrite | eUserExec
, eGroupRWX = eGroupRead | eGroupWrite | eGroupExec
, eOthersRWX = eOthersRead | eOthersWrite | eOthersExec
,
eAllRWX = eUserRWX | eGroupRWX | eOthersRWX
} |
| | open modes enumerator More...
|
| |
| enum class | OpenMode : uint32_t {
eDummy = 0x00000000
, eRead = 0x00000001
, eWrite = 0x00000002
, eAppend = 0x00000004
,
eBinary = 0x00000008
} |
| | open modes enumerator More...
|
| |
| enum class | OffsetMode : uint8_t {
eBeginning = 0
, eCurrent = 1
, eEnd = 2
, eCount
,
eMin = eBeginning
} |
| | Offset modes enumerator. More...
|
| |
| enum class | EncodingMode : uint8_t {
eAuto = 0
, eASCII = 1
, eUTF8 = 2
, eUTF16 = 3
,
eCount
, eMin = eAuto
} |
| | Text file encoding mode. More...
|
| |
| using | TraverseDirFunction = castor::Function< bool( Path const & path ) > |
| |
| using | HitFileFunction = castor::Function< void( Path const & folder, String const & name ) > |
| |
| using | FilterFunction = castor::Function< bool( Path const & folder, String const & name ) > |
| |
|
| static CU_API bool | traverseDirectory (Path const &folderPath, TraverseDirFunction const &directoryFunction, HitFileFunction const &fileFunction) |
| | Traverses the files and directories of a directory.
|
| |
| static CU_API PathArray | filterDirectoryFiles (Path const &folderPath, FilterFunction const &onFile, bool recursive=false) |
| | Filters the files in a directory, recursively or not.
|
| |
| static CU_API bool | listDirectoryFiles (Path const &folderPath, PathArray &files, bool recursive=false) |
| | List all files in a directory, recursively or not.
|
| |
| static CU_API Path | getExecutableDirectory () |
| | Gives the current directory (id est where the execution is)
|
| |
| static CU_API Path | getUserDirectory () |
| | Gives the user home directory.
|
| |
| static CU_API bool | directoryExists (Path const &folderPath) |
| | Tests directory existence.
|
| |
| static CU_API bool | directoryCreate (Path const &folderPath, FlagCombination< CreateMode > const &flags=CreateMode::eAllRWX) |
| | Creates a directory.
|
| |
| static CU_API bool | directoryDelete (Path const &folderPath) |
| | Deletes an empty directory.
|
| |
| static CU_API bool | fileExists (Path const &filePath) |
| | Tests file existence.
|
| |
| static CU_API bool | deleteFile (Path const &filePath) |
| | Deletes a file.
|
| |
| static CU_API bool | copyFile (Path const &filePath, Path const &folderPath, bool allowReplace=false) |
| | Copy a file into a folder.
|
| |
| static CU_API bool | copyFileName (Path const &srcFileName, Path const &dstFileName, bool allowReplace=false) |
| | Copies a file.
|
| |
| static CU_API String | normaliseFileName (String const &name, castor::StringView repl=cuT("_")) |
| | Replaces the characters non valid for file name with given replacement character.
|
| |
◆ FilterFunction
◆ HitFileFunction
◆ TraverseDirFunction
◆ CreateMode
open modes enumerator
| Enumerator |
|---|
| eUserRead | Owner can read.
|
| eUserWrite | Owner can write.
|
| eUserExec | Owner can execute.
|
| eGroupRead | Owner group can read.
|
| eGroupWrite | Owner group can write.
|
| eGroupExec | Owner group can execute.
|
| eOthersRead | Others can read.
|
| eOthersWrite | Others can write.
|
| eOthersExec | Others can execute.
|
| eUserRWX | read, write and execution rights for owner.
|
| eGroupRWX | read, write and execution rights for owner group.
|
| eOthersRWX | read, write and execution rights for others.
|
| eAllRWX | read, write and execution rights for all users.
|
◆ EncodingMode
Text file encoding mode.
| Enumerator |
|---|
| eAuto | Auto select text encoding.
|
| eASCII | ASCII text encoding.
|
| eUTF8 | UTF8 text encoding.
|
| eUTF16 | UTF16 text encoding.
|
| eCount | |
| eMin | |
◆ OffsetMode
Offset modes enumerator.
| Enumerator |
|---|
| eBeginning | The offset is set from the beginning of the file.
|
| eCurrent | The offset is set from the current position.
|
| eEnd | The offset is set from the end of the file.
|
| eCount | |
| eMin | |
◆ OpenMode
open modes enumerator
| Enumerator |
|---|
| eDummy | Dummy open mode, not to be used.
|
| eRead | read open mode.
|
| eWrite | write open mode.
|
| eAppend | Append open mode.
|
| eBinary | Binary open mode.
|
◆ File()
Opens the file at the given path with the given mode and encoding.
- Parameters
-
| [in] | filePath | The file path |
| [in] | mode | The opening mode, combination of one or more OpenMode |
| [in] | encoding | The file encoding mode |
◆ ~File()
| virtual CU_API castor::File::~File |
( |
| ) |
|
|
virtualnoexcept |
Destructor, closes the file.
◆ copyFile()
| static CU_API bool castor::File::copyFile |
( |
Path const & | filePath, |
|
|
Path const & | folderPath, |
|
|
bool | allowReplace = false ) |
|
static |
Copy a file into a folder.
- Parameters
-
| [in] | filePath | File name and path. |
| [in] | folderPath | The destination folder. |
| [in] | allowReplace | true to allow existing file replacing. |
- Returns
true if file has been correctly copied.
◆ copyFileName()
| static CU_API bool castor::File::copyFileName |
( |
Path const & | srcFileName, |
|
|
Path const & | dstFileName, |
|
|
bool | allowReplace = false ) |
|
static |
Copies a file.
- Returns
true if file has been correctly copied
◆ CU_DeclareInvariantBlock()
| castor::File::CU_DeclareInvariantBlock |
( |
| ) |
|
|
protected |
◆ deleteFile()
| static CU_API bool castor::File::deleteFile |
( |
Path const & | filePath | ) |
|
|
static |
Deletes a file.
- Parameters
-
| [in] | filePath | File name and path |
- Returns
true if file has been correctly deleted
◆ directoryCreate()
Creates a directory.
- Parameters
-
| [in] | folderPath | Directory path |
| [in] | flags | User rights |
- Returns
true if the directory has been created
◆ directoryDelete()
| static CU_API bool castor::File::directoryDelete |
( |
Path const & | folderPath | ) |
|
|
static |
Deletes an empty directory.
- Parameters
-
| [in] | folderPath | Directory path |
- Returns
true if the directory has been deleted
◆ directoryExists()
| static CU_API bool castor::File::directoryExists |
( |
Path const & | folderPath | ) |
|
|
static |
Tests directory existence.
- Parameters
-
| [in] | folderPath | Directory path |
- Returns
true if directory is found
◆ doRead()
| CU_API uint64_t castor::File::doRead |
( |
uint8_t * | buffer, |
|
|
uint64_t | size ) |
|
protected |
◆ doWrite()
| CU_API uint64_t castor::File::doWrite |
( |
uint8_t const * | buffer, |
|
|
uint64_t | size ) |
|
protected |
◆ fileExists()
| static CU_API bool castor::File::fileExists |
( |
Path const & | filePath | ) |
|
|
static |
Tests file existence.
- Parameters
-
| [in] | filePath | File name and path |
- Returns
true if file is found
◆ filterDirectoryFiles()
| static CU_API PathArray castor::File::filterDirectoryFiles |
( |
Path const & | folderPath, |
|
|
FilterFunction const & | onFile, |
|
|
bool | recursive = false ) |
|
static |
Filters the files in a directory, recursively or not.
- Parameters
-
| [in] | folderPath | The directory path. |
| [in] | onFile | The filter function, returns true to add to the list, false to ignore. |
| [in] | recursive | Tells if search must be recursive. |
- Returns
- The files list.
◆ getExecutableDirectory()
| static CU_API Path castor::File::getExecutableDirectory |
( |
| ) |
|
|
static |
Gives the current directory (id est where the execution is)
- Returns
- The directory
◆ getFileFullPath()
| Path const & castor::File::getFileFullPath |
( |
| ) |
const |
|
inline |
Retrieves the full file path, name and extension.
- Returns
- The value
References m_fileFullPath.
◆ getFileName()
| Path castor::File::getFileName |
( |
| ) |
const |
|
inline |
◆ getFilePath()
| Path castor::File::getFilePath |
( |
| ) |
const |
|
inline |
◆ getLength()
| CU_API long long castor::File::getLength |
( |
| ) |
|
Retrieves the file size.
- Returns
- The value
◆ getUserDirectory()
| static CU_API Path castor::File::getUserDirectory |
( |
| ) |
|
|
static |
Gives the user home directory.
- Returns
- The directory
◆ isOk()
| CU_API bool castor::File::isOk |
( |
| ) |
const |
Tells if the file cursor is OK.
- Returns
true if the file cursor is not in error and not EOF
◆ listDirectoryFiles()
| static CU_API bool castor::File::listDirectoryFiles |
( |
Path const & | folderPath, |
|
|
PathArray & | files, |
|
|
bool | recursive = false ) |
|
static |
List all files in a directory, recursively or not.
- Parameters
-
| [in] | folderPath | The directory path |
| [out] | files | Receives the files list |
| [in] | recursive | Tells if search must be recursive |
- Returns
true if the directory is listed
◆ normaliseFileName()
Replaces the characters non valid for file name with given replacement character.
◆ seek()
sets the cursor in the file according to the given offset and the given mode
- Parameters
-
| [in] | offset | The wanted offset |
| [in] | origin | The offset mode |
- Returns
0 if successful
◆ tell()
| CU_API long long castor::File::tell |
( |
| ) |
|
Retrieves the file cursor position.
- Returns
- The value
◆ traverseDirectory()
Traverses the files and directories of a directory.
- Parameters
-
| [in] | folderPath | The directory path. |
| [in] | directoryFunction | returns true to traverse it, false to ignore. |
| [in] | fileFunction | Placeholder to handle a file name. |
- Returns
false if any error occured.
◆ m_cursor
| uint64_t castor::File::m_cursor { 0 } |
|
protected |
The current cursor position in file.
◆ m_encoding
◆ m_file
| FILE* castor::File::m_file { nullptr } |
|
protected |
◆ m_fileFullPath
| Path castor::File::m_fileFullPath |
|
protected |
◆ m_length
| uint64_t castor::File::m_length { 0 } |
|
protected |
◆ m_mode
The documentation for this class was generated from the following file: