2021-01-28 19:26:41 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <switch.h>
|
|
|
|
|
|
|
|
#define PATH "/switch/aio-switch-updater/"
|
|
|
|
#define FULL_PATH "/switch/aio-switch-updater/aio-switch-updater.nro"
|
|
|
|
#define CONFIG_PATH "/config/aio-switch-updater/switch/aio-switch-updater/aio-switch-updater.nro"
|
|
|
|
#define PREFIX "/switch/aio-switch-updater/aio-switch-updater-v"
|
|
|
|
#define FORWARDER_PATH "/config/aio-switch-updater/aiosu-forwarder.nro"
|
2021-02-16 17:03:14 +00:00
|
|
|
#define CONFIG_SWITCH "/config/aio-switch-updater/switch/"
|
|
|
|
#define HIDDEN_FILE "/config/aio-switch-updater/.aio-switch-updater"
|
2021-01-28 19:26:41 +00:00
|
|
|
|
2021-03-16 02:04:21 +00:00
|
|
|
int util::removeDir(const char* path)
|
2021-02-15 14:19:49 +00:00
|
|
|
{
|
|
|
|
Result ret = 0;
|
|
|
|
FsFileSystem *fs = fsdevGetDeviceFileSystem("sdmc");
|
|
|
|
if (R_FAILED(ret = fsFsDeleteDirectoryRecursively(fs, path))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2021-01-28 19:26:41 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
std::filesystem::create_directory(PATH);
|
|
|
|
for (const auto & entry : std::filesystem::directory_iterator(PATH)){
|
|
|
|
if(entry.path().string().find(PREFIX) != std::string::npos) {
|
|
|
|
std::filesystem::remove(entry.path().string());
|
|
|
|
std::filesystem::remove(entry.path().string() + ".star");
|
|
|
|
}
|
|
|
|
}
|
2021-02-16 17:03:14 +00:00
|
|
|
std::filesystem::remove(HIDDEN_FILE);
|
2021-01-28 19:26:41 +00:00
|
|
|
|
|
|
|
if(std::filesystem::exists(CONFIG_PATH)){
|
|
|
|
std::filesystem::create_directory(PATH);
|
2021-01-28 20:01:50 +00:00
|
|
|
std::filesystem::remove(FULL_PATH);
|
2021-01-28 19:26:41 +00:00
|
|
|
std::filesystem::rename(CONFIG_PATH, FULL_PATH);
|
2021-03-16 02:04:21 +00:00
|
|
|
util::removeDir(CONFIG_SWITCH);
|
2021-01-28 19:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::filesystem::remove(FORWARDER_PATH);
|
|
|
|
|
|
|
|
envSetNextLoad(FULL_PATH, ("\"" + std::string(FULL_PATH) + "\"").c_str());
|
|
|
|
return 0;
|
|
|
|
}
|