适配ZLToolKit

This commit is contained in:
xiongziliang
2023-12-02 19:49:28 +08:00
parent d555f6038a
commit c12a6f0aed
11 changed files with 26 additions and 26 deletions

View File

@@ -25,7 +25,7 @@ void HttpDownloader::startDownload(const string &url, const string &file_path, b
if (_file_path.empty()) {
_file_path = exeDir() + "HttpDownloader/" + MD5(url).hexdigest();
}
_save_file = File::create_file(_file_path.data(), append ? "ab" : "wb");
_save_file = File::create_file(_file_path, append ? "ab" : "wb");
if (!_save_file) {
auto strErr = StrPrinter << "打开文件失败:" << file_path << endl;
throw std::runtime_error(strErr);

View File

@@ -192,7 +192,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
last_dir_name = split(strPathPrefix, "/").back();
}
if (!File::is_dir(strPathPrefix.data())) {
if (!File::is_dir(strPathPrefix)) {
return false;
}
stringstream ss;
@@ -250,7 +250,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
int i = 0;
for (auto &pr :file_map) {
auto &strAbsolutePath = pr.second.second;
bool isDir = File::is_dir(strAbsolutePath.data());
bool isDir = File::is_dir(strAbsolutePath);
ss << "<li><span>" << i++ << "</span>\t";
ss << "<a href=\"";
//路径链接地址
@@ -271,7 +271,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
continue;
}
//是文件
auto fileSize = File::fileSize(strAbsolutePath.data());
auto fileSize = File::fileSize(strAbsolutePath);
if (fileSize < 1024) {
ss << " (" << fileSize << "B)" << endl;
} else if (fileSize < 1024 * 1024) {
@@ -467,7 +467,7 @@ static string pathCat(const string &a, const string &b){
*/
static void accessFile(Session &sender, const Parser &parser, const MediaInfo &media_info, const string &file_path, const HttpFileManager::invoker &cb) {
bool is_hls = end_with(file_path, kHlsSuffix) || end_with(file_path, kHlsFMP4Suffix);
if (!is_hls && !File::fileExist(file_path.data())) {
if (!is_hls && !File::fileExist(file_path)) {
//文件不存在且不是hls,那么直接返回404
sendNotFound(cb);
return;
@@ -628,12 +628,12 @@ void HttpFileManager::onAccessPath(Session &sender, Parser &parser, const HttpFi
return;
}
//访问的是文件夹
if (File::is_dir(file_path.data())) {
if (File::is_dir(file_path)) {
auto indexFile = searchIndexFile(file_path);
if (!indexFile.empty()) {
// 发现该文件夹下有index文件
file_path = pathCat(file_path, indexFile);
if (!File::is_dir(file_path.data())) {
if (!File::is_dir(file_path)) {
// 不是文件夹
parser.setUrl(pathCat(parser.url(), indexFile));
accessFile(sender, parser, media_info, file_path, cb);

View File

@@ -85,10 +85,10 @@ void MP4Recorder::asyncClose() {
TraceL << "Closed tmp mp4 file: " << full_path_tmp;
if (!full_path_tmp.empty()) {
// 获取文件大小
info.file_size = File::fileSize(full_path_tmp.data());
info.file_size = File::fileSize(full_path_tmp);
if (info.file_size < 1024) {
// 录像文件太小,删除之
File::delete_file(full_path_tmp.data());
File::delete_file(full_path_tmp);
return;
}
// 临时文件名改成正式文件名防止mp4未完成时被访问

View File

@@ -174,7 +174,7 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller, const RtmpMediaSou
}
});
//新建文件
_file.reset(File::create_file(file_path.data(), "wb"), [fileBuf](FILE *fp) {
_file.reset(File::create_file(file_path, "wb"), [fileBuf](FILE *fp) {
if (fp) {
fflush(fp);
fclose(fp);

View File

@@ -33,7 +33,7 @@ RtpProcess::RtpProcess(const string &stream_id) {
GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir);
{
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info.stream + ".rtp", dump_dir).data(), "wb") : nullptr;
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info.stream + ".rtp", dump_dir), "wb") : nullptr;
if (fp) {
_save_file_rtp.reset(fp, [](FILE *fp) {
fclose(fp);
@@ -42,7 +42,7 @@ RtpProcess::RtpProcess(const string &stream_id) {
}
{
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info.stream + ".video", dump_dir).data(), "wb") : nullptr;
FILE *fp = !dump_dir.empty() ? File::create_file(File::absolutePath(_media_info.stream + ".video", dump_dir), "wb") : nullptr;
if (fp) {
_save_file_video.reset(fp, [](FILE *fp) {
fclose(fp);