GrabBag/VrUtils/Inc/VrFileUtils.h

45 lines
1.2 KiB
C
Raw Normal View History

2025-07-23 01:35:14 +08:00
#pragma once
#include <iostream>
#include <vector>
namespace CVrFileUtils
{
2025-12-27 09:34:02 +08:00
/// 文件是否存在
2025-07-23 01:35:14 +08:00
bool IsFileExist(const char* pFileName);
2025-12-27 09:34:02 +08:00
/// 文件大小
2025-07-23 01:35:14 +08:00
size_t GetFileSize(const char* fileName);
2025-12-27 09:34:02 +08:00
/// 写文件
2025-07-23 01:35:14 +08:00
bool WriteFileData(const char* pFileName, const char* pData, const size_t nLen, bool isAppend = false);
2025-12-27 09:34:02 +08:00
/// 读文件
2025-07-23 01:35:14 +08:00
bool ReadFileData(const char* pFileName, char* pData, size_t* pLen, const int nOffset = 0);
2025-12-27 09:34:02 +08:00
/// 获取目录下所有的文件
2025-07-23 01:35:14 +08:00
bool GetFileList(std::string& pDirPath, std::string exd, std::vector<std::string>& vetFiles);
2025-12-27 09:34:02 +08:00
/// 获取目录下所有目录
2025-07-23 01:35:14 +08:00
bool GetDirList(std::string& pDirPath, std::vector<std::string>& vetFiles);
2025-12-27 09:34:02 +08:00
/// 文件重命名
2025-07-23 01:35:14 +08:00
bool ReNameFile(const char* oldName, const char* newName);
2025-12-27 09:34:02 +08:00
/// 删除文件
2025-07-23 01:35:14 +08:00
bool DeleteLocalFile(const char* sFileName);
2025-12-27 09:34:02 +08:00
/*******目录操作*******/
/// 目录是否存在
2025-07-23 01:35:14 +08:00
bool IsDirExist(const char* szDirectory);
2025-12-27 09:34:02 +08:00
/// 创建新的文件夹
2025-07-23 01:35:14 +08:00
bool CreatNewDir(const char* szPath);
2025-12-27 09:34:02 +08:00
/// 删除目录
2025-07-23 01:35:14 +08:00
bool DeleteDir(const char* szDirPath);
2025-12-27 09:34:02 +08:00
/// 去除后缀获取文件名称
2025-07-23 01:35:14 +08:00
std::string GetFileName(const std::string& filePath, bool bHasSuffix = true);
} // namespace name