13 std::vector<std::filesystem::path> search_paths;
20 search_paths.push_back(std::filesystem::path(bundle_root) /
"Contents" /
"Resources" / relative_path);
23 search_paths.push_back(std::filesystem::path(bundle_root) /
"Resources" / relative_path);
26 search_paths.push_back(std::filesystem::path(bundle_root) /
".." /
".." /
".." /
"assets" / relative_path);
27 search_paths.push_back(std::filesystem::path(bundle_root) /
".." /
".." /
".." /
".." /
"assets" / relative_path);
31 search_paths.push_back(std::filesystem::path(
"assets") / relative_path);
32 search_paths.push_back(std::filesystem::path(
"../assets") / relative_path);
33 search_paths.push_back(std::filesystem::path(
"../../assets") / relative_path);
34 search_paths.push_back(std::filesystem::path(
"../../../assets") / relative_path);
35 search_paths.push_back(std::filesystem::path(
"../../../../assets") / relative_path);
38 search_paths.push_back(std::filesystem::path(
"build/assets") / relative_path);
39 search_paths.push_back(std::filesystem::path(
"../build/assets") / relative_path);
47 for (
const auto& path : search_paths) {
48 if (std::filesystem::exists(path)) {
54 std::string searched_paths;
55 for (
const auto& path : search_paths) {
56 searched_paths +=
"\n - " + path.string();
59 return absl::NotFoundError(
60 absl::StrFormat(
"Asset file not found: %s\nSearched paths:%s",
61 relative_path, searched_paths));
66 if (!path_result.ok()) {
67 return path_result.status();
70 const auto& path = *path_result;
71 std::ifstream file(path);
72 if (!file.is_open()) {
73 return absl::InternalError(
74 absl::StrFormat(
"Failed to open file: %s", path.string()));
77 std::stringstream buffer;
78 buffer << file.rdbuf();
79 std::string content = buffer.str();
81 if (content.empty()) {
82 return absl::InternalError(
83 absl::StrFormat(
"File is empty: %s", path.string()));