STTNet 0.7.0
载入中...
搜索中...
未找到
stt::file::FileTool类 参考

提供文件操作的静态函数工具类 更多...

#include <sttnet.h>

类 stt::file::FileTool 继承关系图:
stt::file::File stt::file::LogFile

静态 Public 成员函数

static bool createDir (const std::string &ddir, const mode_t &mode=0775)
 新建一个目录
 
static bool copy (const std::string &sourceFile, const std::string &objectFile)
 复制文件
 
static bool createFile (const std::string &filePath, const mode_t &mode=0666)
 新建一个文件
 
static size_t get_file_size (const std::string &fileName)
 获取文件大小
 

详细描述

目录创建、文件创建、二进制复制和文件大小查询的静态工具。

0.7.0 契约:
  • copy() 按原始字节复制;打开或写入失败时返回 false,不会自动创建目标父目录。
  • get_file_size() 返回 size_t;失败值是 std::numeric_limits<size_t>::max(),不是可直接比较的有符号 -1。

成员函数说明

◆ copy()

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

复制文件

参数
sourceFile源文件路径,可以绝对路径也可以相对路径
objectFile目标文件路径,可以绝对路径也可以相对路径
返回
true 操作成功
false 操作失败
注解
不会自动创造不存在的路径

◆ createDir()

static bool stt::file::FileTool::createDir ( const std::string & ddir,
const mode_t & mode = 0775 )
static

新建一个目录

参数
ddir目录路径,可以绝对路径也可以相对路径
mode位掩码表示新建目录的权限(默认为0775 即rwx rwx r-x)
返回
true 操作成功
false 操作失败

◆ createFile()

static bool stt::file::FileTool::createFile ( const std::string & filePath,
const mode_t & mode = 0666 )
static

新建一个文件

参数
filePath文件路径,可以绝对路径也可以相对路径
mode位掩码表示新建文件的权限(默认为0666 即rw- rw- rw-)
返回
true 操作成功
false 操作失败
注解
会自动创造原本不存在的路径

◆ get_file_size()

static size_t stt::file::FileTool::get_file_size ( const std::string & fileName)
static

获取文件大小

参数
fileName文件名字(可以填绝对路径也可以填相对路径)
返回
>=0 返回文件大小
-1 获取文件大小失败

该类的文档由以下文件生成: