Files
panopainter/src/platform_api/asset_file_load_policy.cpp

34 lines
925 B
C++

#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
}
}