dl
dl_file.h
浏览该文件的文档.
1
29#pragma once
30
31//#include <filesystem>
32#include <string>
33#include <vector>
34#include <fstream>
35
36#include "base/dl_tree.h"
37#include "memory/dl_buffer.h"
38
39namespace dl::File
40{
41
42
50void GetPathFileAll(std::string_view path, std::vector<std::string>& ret,
51 std::string_view regex = "", bool recursion = true);
52
61void GetPathContent(std::string_view path, std::vector<std::string>& ret,
62 std::string_view regex = "", bool folder = true, bool file = true);
63
69void GetPathContentAll(std::string_view path, NTree<std::string>& ret);
70
79FILE* GetFile(std::string_view path_name, bool is_binary = true);
80
81std::ifstream Get(std::string_view path_name, bool is_binary = true);
82
89bool ConvertMb2U8(std::string_view path_name, std::string_view out);
90
95std::string GetString(std::string_view path_name);
96
102Buffer GetBuffer(std::string_view path_name);
103
109Buffer GetBuffer(std::ifstream& ifs);
110
116bool SaveBuffer(BufferView buf, std::string_view path_name);
117
119//* @brief 返回文件Blake2b值
120//* @param[in] path_name 路径名称
121//* @param[out] Blake2b 返回值(512位)
122//*/
123//bool HashBlake2b(std::string_view path_name, Crypto::Blake2b& blake2b);
124//
126//* @brief 效验文件Blake2b值
127//* @param[in] path_name 路径名称
128//* @param[in] digest 消息摘要(512位)
129//*/
130//bool HashBlake2bCheck(std::string_view path_name, const Crypto::Blake2b& digest);
131
137uint32_t GetCrc32(std::string_view path_name);
138
139
145bool IsExist(std::string_view path_name);
146
153bool Delete(std::string_view path_name, bool all = false);
154
160void DeleteContent(std::string_view path_name);
161
168bool Copy(std::string_view source, std::string_view target);
169
175std::string GetExtension(std::string_view path_name, bool has_dot = false);
176
182std::string GetFilename(std::string_view path_name);
188std::string GetStem(std::string_view path_name);
194std::string GetFolderName(std::string_view path_name);
200std::string GetFilePath(std::string_view path_name);
201
206bool CreateFolder(std::string_view path);
207
213time_t GetLastWriteTime(std::string_view path_name);
214
215
216
227bool CheckPathFileModified(std::string_view path_name, std::string_view cache, bool update);
228
229//----------------------------常见路径----------------------------
236std::string PathCurrent();
242std::string PathTemp();
249std::string PathStorage();
257std::string PathPrivate();
264std::string PathPublic();
265
266
268//string LastWriteTimeTostring(const std::file_time_type& ftime)
269//{
270// string str;
271// std::time_t cftime = file_time_type::clock::time_point(ftime).time_since_epoch();
272// std::time_t cftime = std::chrono::system_clock::to_time_t();
273// return std::asctime(std::localtime(&cftime));
274//}
275
277
278}
表示一段内存
void DeleteContent(std::string_view path_name)
删除文件夹内容,但不删除文件夹
uint32_t GetCrc32(std::string_view path_name)
‍**
FILE * GetFile(std::string_view path_name, bool is_binary=true)
打开一个文件(只读),可能从压缩包内读取
std::string GetStem(std::string_view path_name)
返回文件名不含后缀
bool CheckPathFileModified(std::string_view path_name, std::string_view cache, bool update)
判断路径内的文件是否有修改(包括增加、删除文件)
void GetPathFileAll(std::string_view path, std::vector< std::string > &ret, std::string_view regex="", bool recursion=true)
获取文件夹所有文件
bool IsExist(std::string_view path_name)
返回文件是否存在
void GetPathContent(std::string_view path, std::vector< std::string > &ret, std::string_view regex="", bool folder=true, bool file=true)
获取文件夹当前内容
void GetPathContentAll(std::string_view path, NTree< std::string > &ret)
获取文件夹所有内容
std::string GetExtension(std::string_view path_name, bool has_dot=false)
返回文件后缀
std::ifstream Get(std::string_view path_name, bool is_binary=true)
std::string PathCurrent()
返回资源路径
std::string GetFolderName(std::string_view path_name)
返回路径所在文件夹名
std::string PathPrivate()
返回私有路径 rw
bool SaveBuffer(BufferView buf, std::string_view path_name)
将内存保存为文件
time_t GetLastWriteTime(std::string_view path_name)
返回文件最后修改时间
bool ConvertMb2U8(std::string_view path_name, std::string_view out)
将文本文件从mb转到utf-8
std::string GetFilePath(std::string_view path_name)
返回文件所在路径
std::string PathPublic()
返回公共路径 rw
bool Delete(std::string_view path_name, bool all=false)
删除文件或路径
bool CreateFolder(std::string_view path)
创建目录
std::string PathTemp()
返回临时路径 rw
void InitFileSystem()
std::string GetFilename(std::string_view path_name)
返回文件名
std::string GetString(std::string_view path_name)
按文本读文件
std::string PathStorage()
返回存储路径 rw(安卓只读)
Buffer GetBuffer(std::string_view path_name)
返回文件内存
bool Copy(std::string_view source, std::string_view target)
复制文件
std::span< std::byte > BufferView
Definition: dl_buffer.h:22
std::vector< std::byte > Buffer
Definition: dl_buffer.h:21