Reformat file size
This commit is contained in:
@@ -9,13 +9,16 @@
|
|||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
|
||||||
static std::string formatBytes(uint64_t bytes) {
|
static std::string formatBytes(uint64_t bytes) {
|
||||||
if (bytes >= 1024ULL * 1024 * 1024) {
|
|
||||||
char buf[16];
|
|
||||||
snprintf(buf, sizeof(buf), "%.1f GB", bytes / (1024.0 * 1024 * 1024));
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
char buf[16];
|
char buf[16];
|
||||||
snprintf(buf, sizeof(buf), "%u MB", static_cast<unsigned>(bytes / (1024 * 1024)));
|
if (bytes >= 1024ULL * 1024 * 1024) {
|
||||||
|
snprintf(buf, sizeof(buf), "%.1f GB", bytes / (1024.0 * 1024.0 * 1024.0));
|
||||||
|
} else if (bytes >= 1024ULL * 1024) {
|
||||||
|
snprintf(buf, sizeof(buf), "%.1f MB", bytes / (1024.0 * 1024.0));
|
||||||
|
} else if (bytes >= 1024ULL) {
|
||||||
|
snprintf(buf, sizeof(buf), "%.1f KB", bytes / 1024.0);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, sizeof(buf), "%llu B", static_cast<unsigned long long>(bytes));
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class CrossPointWebServer {
|
|||||||
|
|
||||||
// File scanning
|
// File scanning
|
||||||
void scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const;
|
void scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const;
|
||||||
String formatFileSize(size_t bytes) const;
|
|
||||||
bool isEpubFile(const String& filename) const;
|
bool isEpubFile(const String& filename) const;
|
||||||
|
|
||||||
// Request handlers
|
// Request handlers
|
||||||
|
|||||||
Reference in New Issue
Block a user