STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Static Public Member Functions | List of all members
stt::file::FileTool Class Reference

A utility class that provides static functions for file operations. More...

#include <sttnet_English.h>

Inheritance diagram for stt::file::FileTool:
stt::file::File stt::file::LogFile

Static Public Member Functions

static bool createDir (const std::string &ddir, const mode_t &mode=0775)
 Create a new directory. More...
 
static bool copy (const std::string &sourceFile, const std::string &objectFile)
 Copy a file. More...
 
static bool createFile (const std::string &filePath, const mode_t &mode=0666)
 Create a new file. More...
 
static size_t get_file_size (const std::string &fileName)
 Get the size of a file. More...
 

Detailed Description

A utility class that provides static functions for file operations.

Member Function Documentation

static bool stt::file::FileTool::copy ( const std::string &  sourceFile,
const std::string &  objectFile 
)
static

Copy a file.

Parameters
sourceFileThe path of the source file, which can be an absolute or relative path.
objectFileThe path of the target file, which can be an absolute or relative path.
Returns
true if the operation is successful.
false if the operation fails.
Note
Non-existent paths will not be created automatically.
static bool stt::file::FileTool::createDir ( const std::string &  ddir,
const mode_t &  mode = 0775 
)
static

Create a new directory.

Parameters
ddirThe directory path, which can be an absolute or relative path.
modeA bit mask representing the permissions of the newly created directory (default is 0775, i.e., rwx rwx r-x).
Returns
true if the operation is successful.
false if the operation fails.
static bool stt::file::FileTool::createFile ( const std::string &  filePath,
const mode_t &  mode = 0666 
)
static

Create a new file.

Parameters
filePathThe file path, which can be an absolute or relative path.
modeA bit mask representing the permissions of the newly created file (default is 0666, i.e., rw- rw- rw-).
Returns
true if the operation is successful.
false if the operation fails.
Note
Non-existent paths will be created automatically.
static size_t stt::file::FileTool::get_file_size ( const std::string &  fileName)
static

Get the size of a file.

Parameters
fileNameThe name of the file (can be an absolute or relative path).
Returns
>=0 Returns the file size.
-1 Failed to get the file size.

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