mirror of
https://gitlab.com/parallel-launcher/parallel-launcher
synced 2025-10-05 16:12:45 +02:00
Fixed MacOS build
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <Windows.h>
|
||||
#include <sys/utime.h>
|
||||
|
||||
int64 Time::getLastModifiedSec( const fs::path &path ) {
|
||||
struct __stat64 fileInfo;
|
||||
@@ -46,8 +47,17 @@ int64 Time::getLastModifiedMs( const fs::path &path ) {
|
||||
return (ticks / 10000ll) - 11644473600000ll;
|
||||
}
|
||||
|
||||
bool Time::setLastModifiedSec( const fs::path &path, int64 sec ) {
|
||||
__utimbuf64 ts;
|
||||
ts.actime = sec;
|
||||
ts.modtime = sec;
|
||||
return _wutime64( path.wstring().c_str(), &ts ) == 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <utime.h>
|
||||
|
||||
static inline timespec getLastModifiedTs( const fs::path &path ) {
|
||||
struct stat fileInfo;
|
||||
if( ::stat( path.c_str(), &fileInfo ) < 0 ) {
|
||||
@@ -69,5 +79,12 @@ int64 Time::getLastModifiedMs( const fs::path &path ) {
|
||||
return (1000ll * (int64)ts.tv_sec) + ((int64)ts.tv_nsec / 1000000ll);
|
||||
}
|
||||
|
||||
bool Time::setLastModifiedSec( const fs::path &path, int64 sec ) {
|
||||
utimbuf ts;
|
||||
ts.actime = (time_t)sec;
|
||||
ts.modtime = (time_t)sec;
|
||||
return ::utime( path.c_str(), &ts ) == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -9,6 +9,8 @@ namespace Time {
|
||||
extern int64 getLastModifiedSec( const fs::path &path );
|
||||
extern int64 getLastModifiedMs( const fs::path &path );
|
||||
|
||||
extern bool setLastModifiedSec( const fs::path &path, int64 sec );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include <QFile>
|
||||
#include <unordered_map>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include "src/polyfill/file.hpp"
|
||||
#include "src/polyfill/filetime.hpp"
|
||||
#include "src/db/data-provider.hpp"
|
||||
@@ -132,15 +131,6 @@ static std::vector<int> getLocalStarCounts( const string &hackId ) {
|
||||
return layout.countAllStars( saveFilePath );
|
||||
}
|
||||
|
||||
static inline bool setFileTime( const fs::path filePath, int64 unixTime ) {
|
||||
const int64 epochDiff = Time::now() - (int64)std::chrono::duration_cast<std::chrono::seconds>( fs::file_time_type::clock::now().time_since_epoch() ).count();
|
||||
const auto fileTime = fs::file_time_type::clock::time_point() + std::chrono::seconds( unixTime - epochDiff );
|
||||
|
||||
fs::error_code err;
|
||||
fs::last_write_time( filePath, fileTime, err );
|
||||
return !err;
|
||||
}
|
||||
|
||||
static inline bool countsNotGreater( const std::vector<int> &a, const std::vector<int> &b ) {
|
||||
if( a.size() != b.size() ) return false;
|
||||
for( size_t i = 0; i < a.size(); i++ ) {
|
||||
@@ -194,7 +184,7 @@ void RhdcCloudSave::synchronizeSaveFile(
|
||||
RhdcCloudSave &save = g_cloudSaves[hackId];
|
||||
save.localTimestamp = save.cloudTimestamp = cloudSaveDate.toSecsSinceEpoch();
|
||||
save.localProgress = getLocalStarCounts( hackId );
|
||||
setFileTime( RetroArch::getGroupSaveFilePath( hackId ), save.localTimestamp.value() );
|
||||
Time::setLastModifiedSec( RetroArch::getGroupSaveFilePath( hackId ), save.localTimestamp.value() );
|
||||
save.status = CloudSaveStatus::Synced;
|
||||
emitChangeEvent( hackId );
|
||||
callback( CloudSaveStatus::Synced );
|
||||
@@ -205,7 +195,7 @@ void RhdcCloudSave::synchronizeSaveFile(
|
||||
}
|
||||
},
|
||||
[hackId,callback](const QDateTime &cloudSaveDate) {
|
||||
setFileTime( RetroArch::getGroupSaveFilePath( hackId ), cloudSaveDate.toSecsSinceEpoch() );
|
||||
Time::setLastModifiedSec( RetroArch::getGroupSaveFilePath( hackId ), cloudSaveDate.toSecsSinceEpoch() );
|
||||
g_cloudSaves[hackId].status = CloudSaveStatus::Synced;
|
||||
emitChangeEvent( hackId );
|
||||
callback( CloudSaveStatus::Synced );
|
||||
@@ -423,7 +413,7 @@ void RhdcCloudSave::forceSyncCloudToLocal(
|
||||
RhdcCloudSave &save = g_cloudSaves[hackId];
|
||||
save.localTimestamp = save.cloudTimestamp = lastModified.toSecsSinceEpoch();
|
||||
save.localProgress = getLocalStarCounts( hackId );
|
||||
setFileTime( RetroArch::getGroupSaveFilePath( hackId ), save.localTimestamp.value() );
|
||||
Time::setLastModifiedSec( RetroArch::getGroupSaveFilePath( hackId ), save.localTimestamp.value() );
|
||||
save.status = CloudSaveStatus::Synced;
|
||||
emitChangeEvent( hackId );
|
||||
callback( CloudSaveStatus::Synced );
|
||||
|
@@ -25,7 +25,6 @@ RhdcCloudStatusWidget::RhdcCloudStatusWidget( QWidget *parent ) :
|
||||
layout->addStretch( 1 );
|
||||
|
||||
UiUtil::setIconSize( m_button, 16 );
|
||||
UiUtil::fixFontSizeOnMac( m_text );
|
||||
|
||||
connect( m_button, &QPushButton::clicked, this, &RhdcCloudStatusWidget::onButtonClick );
|
||||
RhdcCloudSave::registerChangeListener( this, &RhdcCloudStatusWidget::onStatusChange );
|
||||
|
Reference in New Issue
Block a user