Small Fixes To The Launcher
This commit is contained in:
parent
f328800ce8
commit
34ef2d51aa
@ -183,7 +183,7 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy SDK Into ~/.minecraft-pi
|
// 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;
|
int status = 0;
|
||||||
char *output = run_command(command, &status);
|
char *output = run_command(command, &status);
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void run_simple_command(const char *const command[], const char *error);
|
||||||
|
|
||||||
void pre_bootstrap(int argc, char *argv[]);
|
void pre_bootstrap(int argc, char *argv[]);
|
||||||
void bootstrap(int argc, char *argv[]);
|
void bootstrap(int argc, char *argv[]);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ static std::string get_cache_path() {
|
|||||||
if (home == NULL) {
|
if (home == NULL) {
|
||||||
IMPOSSIBLE();
|
IMPOSSIBLE();
|
||||||
}
|
}
|
||||||
return std::string(home) + "/.minecraft-pi/.launcher-cache";
|
return std::string(home) + HOME_SUBDIRECTORY_FOR_GAME_DATA "/.launcher-cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
@ -44,7 +44,11 @@ launcher_cache load_cache() {
|
|||||||
unsigned char cache_version;
|
unsigned char cache_version;
|
||||||
stream.read((char *) &cache_version, 1);
|
stream.read((char *) &cache_version, 1);
|
||||||
if (stream.eof() || cache_version != (unsigned char) CACHE_VERSION) {
|
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();
|
stream.close();
|
||||||
return empty_cache;
|
return empty_cache;
|
||||||
}
|
}
|
||||||
@ -68,7 +72,7 @@ launcher_cache load_cache() {
|
|||||||
// Finish
|
// Finish
|
||||||
stream.close();
|
stream.close();
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
WARN("Failure While Loading Launcher Cache: %s", strerror(errno));
|
WARN("Failure While Loading Launcher Cache");
|
||||||
return empty_cache;
|
return empty_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,22 +205,11 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create ~/.minecraft-pi If Needed
|
// Create ~/.minecraft-pi If Needed
|
||||||
// Minecraft Folder
|
|
||||||
{
|
{
|
||||||
char *minecraft_folder = NULL;
|
char *minecraft_folder = NULL;
|
||||||
safe_asprintf(&minecraft_folder, "%s/.minecraft-pi", getenv("HOME"));
|
safe_asprintf(&minecraft_folder, "%s" HOME_SUBDIRECTORY_FOR_GAME_DATA, getenv("HOME"));
|
||||||
{
|
const char *const command[] = {"mkdir", "-p", minecraft_folder, NULL};
|
||||||
// Check Minecraft Folder
|
run_simple_command(command, "Unable To Create Data Directory");
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(minecraft_folder);
|
free(minecraft_folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user