Add some prototype UI for overwriting saves

This commit is contained in:
Henrik Rydgård committed 2024-09-05 20:52:12 +02:00
1 parent 3a047369fd
commit f38cc4a959
3 files changed
+30 -1

No files matched your search

+19
View File
@@ -37,6 +37,9 @@
#include <ctime>
#include <memory>
#include <sys/utime.h>
#include <sys/types.h>
#include "Common/Log.h"
#include "Common/LogReporting.h"
#include "Common/File/AndroidContentURI.h"
@@ -1240,4 +1243,20 @@ bool WriteDataToFile(bool text_file, const void* data, size_t size, const Path &
return true;
}
void ChangeMTime(const Path &path, time_t mtime) {
if (path.Type() == PathType::CONTENT_URI) {
// No clue what to do here.
return;
}
_utimbuf buf{};
buf.actime = mtime;
buf.modtime = mtime;
#ifdef _WIN32
_utime(path.c_str(), &buf);
#else
utime(path.c_str(), &buf);
#endif
}
} // namespace File
+2
View File
@@ -83,6 +83,8 @@ uint64_t ComputeRecursiveDirectorySize(const Path &path);
// Returns true if successful, or path already exists.
bool CreateDir(const Path &filename);
void ChangeMTime(const Path &path, time_t mtime);
// Creates the full path of fullPath returns true on success
bool CreateFullPath(const Path &fullPath);
+9 -1
View File
@@ -24,13 +24,15 @@
#include <set>
#include <sstream>
#include <thread>
#include <sys/types.h>
#include <sys/utime.h>
#ifdef SHARED_LIBZIP
#include <zip.h>
#else
#include "ext/libzip/zip.h"
#endif
#ifdef _WIN32
#include "Common/CommonWindows.h"
#endif
#include "Common/Data/Encoding/Utf8.h"
@@ -652,8 +654,14 @@ bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFile
*bytesCopied += readSize;
installProgress_ = (float)*bytesCopied / (float)allBytes;
}
zip_fclose(zf);
fclose(f);
// Copy the mtime, too. May not be possible on Android?
if (zstat.mtime) {
File::ChangeMTime(outFilename, zstat.mtime);
}
delete[] buffer;
return true;
} else {