Small Fixes To The Launcher

This commit is contained in:
TheBrokenRail 2022-09-22 18:08:12 -04:00
parent f328800ce8
commit 34ef2d51aa
4 changed files with 13 additions and 18 deletions

View File

@ -183,7 +183,7 @@ void pre_bootstrap(int argc, char *argv[]) {
}
// Copy SDK Into ~/.minecraft-pi
static void run_simple_command(const char *const command[], const char *error) {
void run_simple_command(const char *const command[], const char *error) {
int status = 0;
char *output = run_command(command, &status);
if (output != NULL) {

View File

@ -4,6 +4,8 @@
extern "C" {
#endif
void run_simple_command(const char *const command[], const char *error);
void pre_bootstrap(int argc, char *argv[]);
void bootstrap(int argc, char *argv[]);

View File

@ -16,7 +16,7 @@ static std::string get_cache_path() {
if (home == NULL) {
IMPOSSIBLE();
}
return std::string(home) + "/.minecraft-pi/.launcher-cache";
return std::string(home) + HOME_SUBDIRECTORY_FOR_GAME_DATA "/.launcher-cache";
}
// Load
@ -44,7 +44,11 @@ launcher_cache load_cache() {
unsigned char cache_version;
stream.read((char *) &cache_version, 1);
if (stream.eof() || cache_version != (unsigned char) CACHE_VERSION) {
WARN("Invalid Launcher Cache Version");
if (!stream.eof()) {
WARN("Invalid Launcher Cache Version (Expected: %i, Actual: %i)", CACHE_VERSION, cache_version);
} else {
WARN("Unable To Read Launcher Cache Version");
}
stream.close();
return empty_cache;
}
@ -68,7 +72,7 @@ launcher_cache load_cache() {
// Finish
stream.close();
if (!stream) {
WARN("Failure While Loading Launcher Cache: %s", strerror(errno));
WARN("Failure While Loading Launcher Cache");
return empty_cache;
}

View File

@ -205,22 +205,11 @@ int main(int argc, char *argv[]) {
}
// Create ~/.minecraft-pi If Needed
// Minecraft Folder
{
char *minecraft_folder = NULL;
safe_asprintf(&minecraft_folder, "%s/.minecraft-pi", getenv("HOME"));
{
// Check Minecraft Folder
struct stat obj;
if (stat(minecraft_folder, &obj) != 0 || !S_ISDIR(obj.st_mode)) {
// Create Minecraft Folder
int ret = mkdir(minecraft_folder, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (ret != 0) {
// Unable To Create Folder
ERR("Error Creating Directory: %s: %s", minecraft_folder, strerror(errno));
}
}
}
safe_asprintf(&minecraft_folder, "%s" HOME_SUBDIRECTORY_FOR_GAME_DATA, getenv("HOME"));
const char *const command[] = {"mkdir", "-p", minecraft_folder, NULL};
run_simple_command(command, "Unable To Create Data Directory");
free(minecraft_folder);
}