sys_fs: Savestate fixup

This commit is contained in:
Eladash 2023-10-03 16:03:07 +03:00 committed by Elad Ashkenazi
parent f88443afa3
commit 0240a7d43d
4 changed files with 12 additions and 8 deletions

View File

@ -447,8 +447,11 @@ lv2_file::lv2_file(utils::serial& ar)
if (ar.operator bool()) // see lv2_file::save in_mem
{
std::vector<u8> buf = ar;
const fs::stat_t stat = ar;
std::vector<u8> buf(stat.size);
ar(std::span<u8>(buf.data(), buf.size()));
file = fs::make_stream<std::vector<u8>>(std::move(buf), stat);
}
@ -514,6 +517,10 @@ void lv2_file::save(utils::serial& ar)
sys_fs.error("Saving \'%s\' LV2 file descriptor in memory! (exists=%s, type=%s, flags=0x%x, size=0x%x)", name.data(), fs::is_file(real_path), type, flags, stats.size);
const usz patch_stats_pos = ar.seek_end();
ar(stats);
const usz old_end = ar.pad_from_end(stats.size);
if (usz read_size = file.read_at(0, &ar.data[old_end], stats.size); read_size != stats.size)
@ -522,9 +529,8 @@ void lv2_file::save(utils::serial& ar)
sys_fs.error("Read less than expected! (new-size=0x%x)", read_size);
stats.size = read_size;
ar.data.resize(old_end + stats.size);
write_to_ptr<fs::stat_t>(&ar.data[patch_stats_pos], stats);
}
ar(stats);
}
ar(file.pos());

View File

@ -199,7 +199,7 @@ struct CellFsMountInfo; // Forward Declaration
struct lv2_fs_mount_info_map
{
public:
SAVESTATE_INIT_POS(49);
SAVESTATE_INIT_POS(40);
lv2_fs_mount_info_map();
lv2_fs_mount_info_map(const lv2_fs_mount_info_map&) = delete;
@ -228,7 +228,7 @@ struct lv2_fs_object
static constexpr u32 id_step = 1;
static constexpr u32 id_count = 255 - id_base;
static constexpr bool id_lowest = true;
SAVESTATE_INIT_POS(40);
SAVESTATE_INIT_POS(49);
// File Name (max 1055)
const std::array<char, 0x420> name;

View File

@ -31,8 +31,6 @@ struct vfs_manager
// VFS root
vfs_directory root{};
SAVESTATE_INIT_POS(48);
};
bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir)

View File

@ -35,7 +35,7 @@ static std::array<serial_ver_t, 26> s_serial_versions;
return ::s_serial_versions[identifier].current_version;\
}
SERIALIZATION_VER(global_version, 0, 14) // For stuff not listed here
SERIALIZATION_VER(global_version, 0, 15) // For stuff not listed here
SERIALIZATION_VER(ppu, 1, 1)
SERIALIZATION_VER(spu, 2, 1)
SERIALIZATION_VER(lv2_sync, 3, 1)