mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
psf: replace filesystem clock by system clock (utc)
This commit is contained in:
parent
d7615ca86a
commit
b8e5501275
@ -21,8 +21,13 @@ static inline u32 get_max_size(std::string_view key, u32 default_value) {
|
||||
}
|
||||
|
||||
bool PSF::Open(const std::filesystem::path& filepath) {
|
||||
using namespace std::chrono;
|
||||
if (std::filesystem::exists(filepath)) {
|
||||
last_write = std::filesystem::last_write_time(filepath);
|
||||
const auto t = std::filesystem::last_write_time(filepath);
|
||||
const auto rel =
|
||||
duration_cast<seconds>(t - std::filesystem::file_time_type::clock::now()).count();
|
||||
const auto tp = system_clock::to_time_t(system_clock::now() + seconds{rel});
|
||||
last_write = system_clock::from_time_t(tp);
|
||||
}
|
||||
|
||||
Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read);
|
||||
@ -99,7 +104,7 @@ bool PSF::Encode(const std::filesystem::path& filepath) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
last_write = std::filesystem::file_time_type::clock::now();
|
||||
last_write = std::chrono::system_clock::now();
|
||||
|
||||
const auto psf_buffer = Encode();
|
||||
const size_t written = file.Write(psf_buffer);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@ -71,7 +72,7 @@ public:
|
||||
void AddString(std::string key, std::string value, bool update = false);
|
||||
void AddInteger(std::string key, s32 value, bool update = false);
|
||||
|
||||
[[nodiscard]] std::filesystem::file_time_type GetLastWrite() const {
|
||||
[[nodiscard]] std::chrono::system_clock::time_point GetLastWrite() const {
|
||||
return last_write;
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::filesystem::file_time_type last_write;
|
||||
mutable std::chrono::system_clock::time_point last_write;
|
||||
|
||||
std::vector<Entry> entry_list;
|
||||
|
||||
|
@ -98,12 +98,14 @@ SaveDialogState::SaveDialogState(const OrbisSaveDataDialogParam& param) {
|
||||
param_sfo.Open(param_sfo_path);
|
||||
|
||||
auto last_write = param_sfo.GetLastWrite();
|
||||
#if defined(_WIN32) && !defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
auto utc_time = std::chrono::file_clock::to_utc(last_write);
|
||||
#ifdef __APPLE__
|
||||
// FIXME: Correct time zone
|
||||
// zoned_time not available on macOS and date/tz.h requires having tzdb downloaded
|
||||
std::string date_str = fmt::format("{:%d %b, %Y %R}", last_write);
|
||||
#else
|
||||
auto utc_time = std::chrono::file_clock::to_sys(last_write);
|
||||
auto t = std::chrono::zoned_time{std::chrono::current_zone(), last_write};
|
||||
std::string date_str = fmt::format("{:%d %b, %Y %R}", t.get_local_time());
|
||||
#endif
|
||||
std::string date_str = fmt::format("{:%d %b, %Y %R}", utc_time);
|
||||
|
||||
size_t size = Common::FS::GetDirectorySize(dir_path);
|
||||
std::string size_str = SpaceSizeToString(size);
|
||||
@ -592,7 +594,7 @@ void SaveDialogUi::DrawList() {
|
||||
int idx = 0;
|
||||
int max_idx = 0;
|
||||
bool is_min = pos == FocusPos::DATAOLDEST;
|
||||
std::filesystem::file_time_type max_write{};
|
||||
std::chrono::system_clock::time_point max_write{};
|
||||
if (state->new_item.has_value()) {
|
||||
idx++;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
std::string date{};
|
||||
std::string size{};
|
||||
|
||||
std::filesystem::file_time_type last_write{};
|
||||
std::chrono::system_clock::time_point last_write{};
|
||||
PSF pfo{};
|
||||
bool is_corrupted{};
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ struct OrbisSaveDataIcon {
|
||||
size_t dataSize;
|
||||
std::array<u8, 32> _reserved;
|
||||
|
||||
Error LoadIcon(const std::filesystem::path& icon_path) {
|
||||
Error LoadIcon(const fs::path& icon_path) {
|
||||
try {
|
||||
const Common::FS::IOFile file(icon_path, Common::FS::FileAccessMode::Read);
|
||||
dataSize = file.GetSize();
|
||||
@ -1232,7 +1232,7 @@ Error PS4_SYSV_ABI sceSaveDataLoadIcon(const OrbisSaveDataMountPoint* mountPoint
|
||||
return Error::PARAMETER;
|
||||
}
|
||||
LOG_DEBUG(Lib_SaveData, "called");
|
||||
std::filesystem::path path;
|
||||
fs::path path;
|
||||
const std::string_view mount_point_str{mountPoint->data};
|
||||
for (const auto& instance : g_mount_slots) {
|
||||
if (instance.has_value() && instance->GetMountPoint() == mount_point_str) {
|
||||
@ -1377,7 +1377,7 @@ Error PS4_SYSV_ABI sceSaveDataSaveIcon(const OrbisSaveDataMountPoint* mountPoint
|
||||
return Error::PARAMETER;
|
||||
}
|
||||
LOG_DEBUG(Lib_SaveData, "called");
|
||||
std::filesystem::path path;
|
||||
fs::path path;
|
||||
const std::string_view mount_point_str{mountPoint->data};
|
||||
for (const auto& instance : g_mount_slots) {
|
||||
if (instance.has_value() && instance->GetMountPoint() == mount_point_str) {
|
||||
|
Loading…
Reference in New Issue
Block a user