diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index eeac63e..4b615f1 100755 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -82,6 +82,8 @@ bool CollectionInfo::Save() std::string file = Utils::combinePath(Configuration::absolutePath, "collections", name, "playlists/favorites.txt"); Logger::write(Logger::ZONE_INFO, "Collection", "Saving " + file); + Utils::rootfsWritable(); + std::ofstream filestream; try { @@ -95,6 +97,7 @@ bool CollectionInfo::Save() if(ERROR_ALREADY_EXISTS != GetLastError()) { Logger::write(Logger::ZONE_WARNING, "Collection", "Could not create directory " + dir); + Utils::rootfsReadOnly(); return false; } } @@ -106,6 +109,7 @@ bool CollectionInfo::Save() #endif { Logger::write(Logger::ZONE_WARNING, "Collection", "Could not create directory " + dir); + Utils::rootfsReadOnly(); return false; } #endif @@ -113,6 +117,7 @@ bool CollectionInfo::Save() else if ( !(info.st_mode & S_IFDIR) ) { Logger::write(Logger::ZONE_WARNING, "Collection", dir + " exists, but is not a directory."); + Utils::rootfsReadOnly(); return false; } @@ -138,6 +143,8 @@ bool CollectionInfo::Save() retval = false; } } + + Utils::rootfsReadOnly(); return retval; } diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index 1e6995b..cd10b10 100755 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -92,6 +92,8 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name) std::string filename = Utils::combinePath(collectionPath, "include.txt"); std::cout << "Creating file \"" << filename << "\"" << std::endl; + Utils::rootfsWritable(); + std::ofstream includeFile; includeFile.open(filename.c_str()); includeFile << "# Add a list of files to show on the menu (one filename per line, without the extension)." << std::endl; @@ -140,6 +142,8 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name) std::ofstream menuFile; menuFile.open(filename.c_str()); menuFile.close(); + + Utils::rootfsReadOnly(); return true; } diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index 3580deb..ec390db 100755 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -287,10 +287,12 @@ bool Configuration::exportCurrentLayout(std::string layoutFilePath, std::string Logger::write(Logger::ZONE_INFO, "Configuration", "Exporting layout \"" + layoutName + "\" in file \"" + layoutFilePath +"\""); + Utils::rootfsWritable(); std::ofstream layoutFile; layoutFile.open(layoutFilePath.c_str()); layoutFile << layoutName << std::endl; layoutFile.close(); + Utils::rootfsReadOnly(); return retVal; } diff --git a/RetroFE/Source/Utility/Utils.cpp b/RetroFE/Source/Utility/Utils.cpp index 7622f31..0a9dd75 100755 --- a/RetroFE/Source/Utility/Utils.cpp +++ b/RetroFE/Source/Utility/Utils.cpp @@ -292,6 +292,22 @@ bool Utils::executeRawPath(const char *shellCmd) return retVal; } +bool Utils::rootfsWritable() +{ + bool retVal = false; + Logger::write(Logger::ZONE_DEBUG, "Utils", "Making rootfs writable with " + std::string(SHELL_CMD_ROOTFS_RW)); + retVal = executeRawPath(SHELL_CMD_ROOTFS_RW); + return retVal; +} + +bool Utils::rootfsReadOnly() +{ + bool retVal = false; + Logger::write(Logger::ZONE_DEBUG, "Utils", "Making rootfs read only with " + std::string(SHELL_CMD_ROOTFS_RO)); + retVal = executeRawPath(SHELL_CMD_ROOTFS_RO); + return retVal; +} + int Utils::termfix(uint32_t ttyId){ // Init tty file path char ttyFilePath[100]; diff --git a/RetroFE/Source/Utility/Utils.h b/RetroFE/Source/Utility/Utils.h index 9f7d620..80aae56 100755 --- a/RetroFE/Source/Utility/Utils.h +++ b/RetroFE/Source/Utility/Utils.h @@ -19,6 +19,10 @@ #include #include #include + +#define SHELL_CMD_ROOTFS_RW "rw" +#define SHELL_CMD_ROOTFS_RO "ro" + class Utils { public: @@ -45,6 +49,8 @@ public: static std::string combinePath(std::string path1, std::string path2, std::string path3, std::string path4, std::string path5); static bool executeRawPath(const char *shellCmd); + static bool rootfsWritable(); + static bool rootfsReadOnly(); static int termfix(uint32_t ttyId); static int getVTid();