fix(libkernel): create /data at start-up

This commit is contained in:
David-cmrg 2026-10-12 20:10:03 +02:00
parent d53960612f
commit bed1b15096
3 changed files with 19 additions and 2 deletions

View File

@ -54,6 +54,17 @@ const bool g_downloadDataMounted = [] {
}
}();
const bool g_dataMounted = [] {
try {
const auto run = std::filesystem::current_path();
if (!std::filesystem::exists(run / "app0" / "sce_sys" / "param.json")) return false;
std::filesystem::create_directories(run / "data");
return true;
} catch (const std::exception&) {
return false;
}
}();
void ensureIconLoaded() {
if (g_iconAttempted) return;
g_iconAttempted = true;

View File

@ -82,12 +82,14 @@ if(BUILD_TESTING)
target_include_directories(download_data_mount_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(download_data_mount_tests PRIVATE libkernel libc)
configure_windows_unwind(download_data_mount_tests)
foreach(downloadDataCase IN ITEMS declared:256 none:0 invalid:256)
foreach(downloadDataCase IN ITEMS declared:256 none:0 invalid:256 missing:0)
string(REPLACE ":" ";" downloadDataCase ${downloadDataCase})
list(GET downloadDataCase 0 downloadDataName)
list(GET downloadDataCase 1 downloadDataSize)
set(downloadDataRun ${CMAKE_CURRENT_BINARY_DIR}/download_data_mount_${downloadDataName})
if(downloadDataName STREQUAL "invalid")
if(downloadDataName STREQUAL "missing")
file(MAKE_DIRECTORY ${downloadDataRun})
elseif(downloadDataName STREQUAL "invalid")
file(WRITE ${downloadDataRun}/app0/sce_sys/param.json "{\"downloadDataSize\":${downloadDataSize}}")
else()
file(WRITE ${downloadDataRun}/app0/sce_sys/param.json

View File

@ -11,6 +11,10 @@ int main(int argc, char** argv) {
Require(argc == 2);
const std::string_view mode = argv[1];
Require(std::filesystem::is_directory("download0") == (mode == "declared"));
const bool data = std::filesystem::is_directory("data");
std::filesystem::remove_all("data");
Require(data == (mode != "missing"));
if (mode == "missing") return 0;
if (mode == "invalid") {
bool rejected = false;
try {