mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 11:26:56 +02:00
Fix save metadata and timestamps
Co-authored-by: Ali Almohaya <AliAlmohaya@gmail.com> Co-authored-by: CheesyPoofs346 <jjs777406@gmail.com>
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
#define EMULATOR_INCLUDE_EMULATOR_LIBS_SAVEDATAMOUNTSLOTS_H_
|
||||
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
|
||||
namespace Libs::SaveData {
|
||||
|
||||
@@ -14,12 +16,15 @@ public:
|
||||
static constexpr int FULL = -1;
|
||||
static constexpr size_t COUNT = 16;
|
||||
|
||||
[[nodiscard]] int FindAvailable(std::string_view directory) const {
|
||||
[[nodiscard]] int FindAvailable(const std::filesystem::path& directory) const {
|
||||
int available = FULL;
|
||||
for (size_t index = 0; index < m_directories.size(); index++) {
|
||||
const auto& mounted = m_directories[index];
|
||||
if (mounted == directory) {
|
||||
return BUSY;
|
||||
if (mounted.has_value()) {
|
||||
std::error_code error;
|
||||
if (*mounted == directory || std::filesystem::equivalent(*mounted, directory, error)) {
|
||||
return BUSY;
|
||||
}
|
||||
}
|
||||
if (!mounted.has_value() && available == FULL) {
|
||||
available = static_cast<int>(index);
|
||||
@@ -28,7 +33,13 @@ public:
|
||||
return available;
|
||||
}
|
||||
|
||||
void Mount(size_t slot, std::string_view directory) { m_directories[slot] = directory; }
|
||||
void Mount(size_t slot, const std::filesystem::path& directory) {
|
||||
m_directories[slot] = directory;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::filesystem::path& Directory(size_t slot) const {
|
||||
return *m_directories[slot];
|
||||
}
|
||||
|
||||
void Release(size_t slot) {
|
||||
if (slot < m_directories.size()) {
|
||||
@@ -59,7 +70,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<std::optional<std::string>, COUNT> m_directories;
|
||||
std::array<std::optional<std::filesystem::path>, COUNT> m_directories;
|
||||
};
|
||||
|
||||
} // namespace Libs::SaveData
|
||||
|
||||
Reference in New Issue
Block a user