dl
dl_file.h
浏览该文件的文档.
1
21#pragma once
22
23//#include <filesystem>
24#include <string>
25#include <vector>
26#include <fstream>
27
28#include "memory/dl_buffer.h"
29
30namespace dl::File
31{
32
33
41void GetPathFileAll(std::string_view path, std::vector<std::string>& ret,
42 std::string_view regex = "", bool recursion = true);
43
44
53FILE* GetFile(std::string_view path_name, bool is_binary = true);
54
55std::ifstream Get(std::string_view path_name, bool is_binary = true);
56
63bool ConvertMb2U8(std::string_view path_name, std::string_view out);
64
70Buffer GetBuffer(std::string_view path_name);
71
77Buffer GetBuffer(std::ifstream& ifs);
78
84bool SaveBuffer(const Buffer& buf, std::string_view path_name);
85
87//* @brief 返回文件Blake2b值
88//* @param[in] path_name 路径名称
89//* @param[out] Blake2b 返回值(512位)
90//*/
91//bool HashBlake2b(std::string_view path_name, Crypto::Blake2b& blake2b);
92//
94//* @brief 效验文件Blake2b值
95//* @param[in] path_name 路径名称
96//* @param[in] digest 消息摘要(512位)
97//*/
98//bool HashBlake2bCheck(std::string_view path_name, const Crypto::Blake2b& digest);
99
105uint32_t GetCrc32(std::string_view path_name);
106
107
113bool IsExist(std::string_view path_name);
114
121bool Delete(std::string_view path_name, bool all = false);
122
128void DeleteContent(std::string_view path_name);
129
136bool Copy(std::string_view source, std::string_view target);
137
143std::string GetExtension(std::string_view path_name, bool has_dot = false);
144
149std::string GetFilename(std::string_view path_name);
150
155std::string GetStem(std::string_view path_name);
160bool CreateDirectory(std::string_view path);
161
167time_t GetLastWriteTime(std::string_view path_name);
168
169
170
181bool CheckPathFileModified(std::string_view path_name, std::string_view cache, bool update);
182
186std::string GetPathCurrent();
187
192std::string GetPathTemp();
193
194
196//string LastWriteTimeTostring(const std::file_time_type& ftime)
197//{
198// string str;
199// std::time_t cftime = file_time_type::clock::time_point(ftime).time_since_epoch();
200// std::time_t cftime = std::chrono::system_clock::to_time_t();
201// return std::asctime(std::localtime(&cftime));
202//}
203
204}
表示一段内存
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)
返回文件是否存在
std::string GetPathCurrent()
返回工作目录
std::string GetExtension(std::string_view path_name, bool has_dot=false)
返回文件后缀
std::ifstream Get(std::string_view path_name, bool is_binary=true)
time_t GetLastWriteTime(std::string_view path_name)
返回文件最后修改时间
bool ConvertMb2U8(std::string_view path_name, std::string_view out)
将文本文件从mb转到utf-8
bool CreateDirectory(std::string_view path)
创建目录
bool Delete(std::string_view path_name, bool all=false)
删除文件或路径
bool SaveBuffer(const Buffer &buf, std::string_view path_name)
将内存保存为文件
std::string GetFilename(std::string_view path_name)
返回文件名
std::string GetPathTemp()
返回临时目录
Buffer GetBuffer(std::string_view path_name)
返回文件内存
bool Copy(std::string_view source, std::string_view target)
复制文件
std::vector< std::byte > Buffer
Definition: dl_buffer.h:21