mirror of
https://github.com/lovell/sharp.git
synced 2026-02-10 16:46:14 +01:00
Support info.size on wide-char systems via upgrade to C++17 #3943
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
@@ -20,17 +21,6 @@
|
||||
#include "operations.h"
|
||||
#include "pipeline.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define STAT64_STRUCT __stat64
|
||||
#define STAT64_FUNCTION _stat64
|
||||
#elif defined(_LARGEFILE64_SOURCE)
|
||||
#define STAT64_STRUCT stat64
|
||||
#define STAT64_FUNCTION stat64
|
||||
#else
|
||||
#define STAT64_STRUCT stat
|
||||
#define STAT64_FUNCTION stat
|
||||
#endif
|
||||
|
||||
class PipelineWorker : public Napi::AsyncWorker {
|
||||
public:
|
||||
PipelineWorker(Napi::Function callback, PipelineBaton *baton,
|
||||
@@ -1306,9 +1296,11 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
Callback().Call(Receiver().Value(), { env.Null(), data, info });
|
||||
} else {
|
||||
// Add file size to info
|
||||
struct STAT64_STRUCT st;
|
||||
if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) {
|
||||
info.Set("size", static_cast<uint32_t>(st.st_size));
|
||||
if (baton->formatOut != "dz" || sharp::IsDzZip(baton->fileOut)) {
|
||||
try {
|
||||
uint32_t const size = static_cast<uint32_t>(std::filesystem::file_size(baton->fileOut));
|
||||
info.Set("size", size);
|
||||
} catch (...) {}
|
||||
}
|
||||
Callback().Call(Receiver().Value(), { env.Null(), info });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user