From b2bb37dc5cd1c4dba001fbf7d6c7054e8aef7b33 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 23 Feb 2022 17:03:13 +0800 Subject: [PATCH] =?UTF-8?q?http:=20=E4=BF=AE=E5=A4=8D32=E4=BD=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=8B=EF=BC=8C=E4=B8=8B=E8=BD=BD3GB=E4=BB=A5?= =?UTF-8?q?=E4=B8=8A=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98:=20#1446?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- src/Http/HttpBody.cpp | 2 +- src/Http/HttpFileManager.cpp | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 6a661111..9d312404 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 6a661111ea029538e1fafa505cb6e8bba8c95551 +Subproject commit 9d3124047d1ec64bf1674ae71bd4fddd728d2243 diff --git a/src/Http/HttpBody.cpp b/src/Http/HttpBody.cpp index 19e41e26..f619286d 100644 --- a/src/Http/HttpBody.cpp +++ b/src/Http/HttpBody.cpp @@ -205,7 +205,7 @@ int64_t HttpFileBody::remainSize() { } Buffer::Ptr HttpFileBody::readData(size_t size) { - size = MIN((size_t)remainSize(), size); + size = (size_t)(MIN(remainSize(), (int64_t)size)); if (!size) { //没有剩余字节了 return nullptr; diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index e4dacc88..f059b27f 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -159,18 +159,15 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st continue; } //是文件 - struct stat fileData; - if (0 == stat(strAbsolutePath.data(), &fileData)) { - auto &fileSize = fileData.st_size; - if (fileSize < 1024) { - ss << " (" << fileData.st_size << "B)" << endl; - } else if (fileSize < 1024 * 1024) { - ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024.0 << "KB)"; - } else if (fileSize < 1024 * 1024 * 1024) { - ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024 / 1024.0 << "MB)"; - } else { - ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024 / 1024 / 1024.0 << "GB)"; - } + auto fileSize = File::fileSize(strAbsolutePath.data()); + if (fileSize < 1024) { + ss << " (" << fileSize << "B)" << endl; + } else if (fileSize < 1024 * 1024) { + ss << fixed << setprecision(2) << " (" << fileSize / 1024.0 << "KB)"; + } else if (fileSize < 1024 * 1024 * 1024) { + ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024.0 << "MB)"; + } else { + ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024 / 1024.0 << "GB)"; } ss << "\r\n"; }