Small Fixes
minecraft-pi-reborn/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2022-09-25 20:56:45 -04:00
parent 8532e7707f
commit 2766611878
3 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.16.0)
# Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0)
cmake_policy(SET CMP0135 NEW)
endif()
# Build Mode
set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code")
set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native")

View File

@ -30,9 +30,6 @@ launcher_cache load_cache() {
// Log
DEBUG("Loading Launcher Cache...");
// Lock File
int lock_fd = lock_file(get_cache_path().c_str());
// Return Value
launcher_cache ret = empty_cache;
@ -46,6 +43,9 @@ launcher_cache load_cache() {
WARN("Unable To Open Launcher Cache For Loading");
}
} else {
// Lock File
int lock_fd = lock_file(get_cache_path().c_str());
// Check Version
unsigned char cache_version;
stream.read((char *) &cache_version, 1);
@ -84,10 +84,10 @@ launcher_cache load_cache() {
ret = cache;
}
}
}
// Unlock File
unlock_file(get_cache_path().c_str(), lock_fd);
// Unlock File
unlock_file(get_cache_path().c_str(), lock_fd);
}
// Return
return ret;
@ -106,15 +106,15 @@ void save_cache() {
// Log
DEBUG("Saving Launcher Cache...");
// Lock File
int lock_fd = lock_file(get_cache_path().c_str());
// Open File
std::ofstream stream(get_cache_path(), std::ios::out | std::ios::binary);
if (!stream) {
// Fail
WARN("Unable To Open Launcher Cache For Saving");
} else {
// Lock File
int lock_fd = lock_file(get_cache_path().c_str());
// Save Cache Version
unsigned char cache_version = (unsigned char) CACHE_VERSION;
stream.write((const char *) &cache_version, 1);
@ -153,10 +153,10 @@ void save_cache() {
if (!stream.good()) {
WARN("Failure While Saving Launcher Cache");
}
}
// Unlock File
unlock_file(get_cache_path().c_str(), lock_fd);
// Unlock File
unlock_file(get_cache_path().c_str(), lock_fd);
}
}
// Wipe Cache

View File

@ -28,7 +28,7 @@ int is_progress_difference_significant(int32_t new_val, int32_t old_val) {
// Lock File
int lock_file(const char *file) {
int fd = open(file, O_WRONLY | O_CREAT, S_IWUSR);
int fd = open(file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd == -1) {
ERR("Unable To Open Lock File: %s: %s", file, strerror(errno));
}