Move layout reload policy into platform api

This commit is contained in:
2026-06-04 18:49:48 +02:00
parent 7aadd1041a
commit 08d8c1e82c
9 changed files with 118 additions and 14 deletions

View File

@@ -0,0 +1,33 @@
#include "platform_api/asset_file_load_policy.h"
#include <string>
#include <sys/stat.h>
namespace pp::platform {
AssetFileLoadDecision plan_asset_file_load(
std::string_view absolute_path,
bool already_loaded,
std::int64_t previous_last_write_time)
{
#if defined(_WIN32) || defined(__OSX__)
struct stat file_info {};
const std::string path(absolute_path);
if (stat(path.c_str(), &file_info) != 0)
return { false, false, previous_last_write_time };
const auto current_last_write_time = static_cast<std::int64_t>(file_info.st_mtime);
if (current_last_write_time <= previous_last_write_time)
return { false, false, previous_last_write_time };
return { true, true, current_last_write_time };
#else
if (already_loaded)
return { false, true, previous_last_write_time };
(void)absolute_path;
return { true, true, previous_last_write_time };
#endif
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include <string_view>
namespace pp::platform {
struct AssetFileLoadDecision {
bool should_read_file = true;
bool skipped_load_result = true;
std::int64_t last_write_time = 0;
};
[[nodiscard]] AssetFileLoadDecision plan_asset_file_load(
std::string_view absolute_path,
bool already_loaded,
std::int64_t previous_last_write_time);
}