diff --git a/ResourceFiles/ResourceFile.cc b/ResourceFiles/ResourceFile.cc index ec72675113..5983be5549 100644 --- a/ResourceFiles/ResourceFile.cc +++ b/ResourceFiles/ResourceFile.cc @@ -3,6 +3,8 @@ #include #include "boost/filesystem/fstream.hpp" +#include +#include #include #include @@ -73,6 +75,13 @@ static void writeMacBinary(std::ostream& out, std::string filename, const std::string& rsrcBytes = resstream.str(); + // Calculate Mac-style timestamp (seconds since 1 January 1904 00:00:00) + std::tm mac_epoch_tm = { + 0, 0, 0, // 00:00:00 + 1, 0, 4 // 1 January 1904 + }; + auto mac_epoch = std::chrono::system_clock::from_time_t(std::mktime(&mac_epoch_tm)); + uint32_t mac_time = std::chrono::duration_cast(std::chrono::system_clock::now() - mac_epoch).count(); std::ostringstream header; byte(header, 0); @@ -91,8 +100,8 @@ static void writeMacBinary(std::ostream& out, std::string filename, byte(header, 0); longword(header, (int)data.size()); longword(header, (int)rsrcBytes.size()); - longword(header, 0); // creation date - longword(header, 0); // modification date + longword(header, mac_time); // creation date + longword(header, mac_time); // modification date while((int)header.tellp() < 124) byte(header,0); std::string headerData = header.str();