diff --git a/Jupiter/File.cpp b/Jupiter/File.cpp index fe504bf..b672130 100644 --- a/Jupiter/File.cpp +++ b/Jupiter/File.cpp @@ -110,7 +110,20 @@ bool Jupiter::File::load(const char *file) { FILE *filePtr = fopen(file, "rb"); if (filePtr == nullptr) return false; - if (Jupiter::File::data_->fileName.size() == 0) Jupiter::File::data_->fileName = file; + if (Jupiter::File::data_->fileName.size() == 0) + Jupiter::File::data_->fileName = file; + bool r = Jupiter::File::load(filePtr); + fclose(filePtr); + return r; +} + +bool Jupiter::File::load(const Jupiter::ReadableString &file) +{ + Jupiter::CStringS fileName = file; + FILE *filePtr = fopen(fileName.c_str(), "rb"); + if (filePtr == nullptr) return false; + if (Jupiter::File::data_->fileName.size() == 0) + Jupiter::File::data_->fileName = file; bool r = Jupiter::File::load(filePtr); fclose(filePtr); return r; @@ -147,6 +160,12 @@ bool Jupiter::File::reload(const char *file) return Jupiter::File::load(file); } +bool Jupiter::File::reload(const Jupiter::ReadableString &file) +{ + Jupiter::File::unload(); + return Jupiter::File::load(file); +} + bool Jupiter::File::reload(FILE *file) { Jupiter::File::unload(); @@ -168,6 +187,11 @@ bool Jupiter::File::sync(const char *file) return true; } +bool Jupiter::File::sync(const Jupiter::ReadableString &file) +{ + return Jupiter::File::sync(Jupiter::CStringS(file).c_str()); +} + bool Jupiter::File::sync(FILE *file) { for (size_t i = 0; i != Jupiter::File::data_->lines.size(); i++) diff --git a/Jupiter/File.h b/Jupiter/File.h index 702eb68..50e9851 100644 --- a/Jupiter/File.h +++ b/Jupiter/File.h @@ -71,6 +71,7 @@ namespace Jupiter * @return True if a file was successfully loaded from the drive, false otherwise. */ bool load(const char *file); + bool load(const Jupiter::ReadableString &file); /** * @brief Loads a file from the drive into this file. @@ -99,6 +100,7 @@ namespace Jupiter * @return True if a file was successfully loaded from the drive, false otherwise. */ bool reload(const char *file); + bool reload(const Jupiter::ReadableString &file); /** * @brief Unloads all of a file's contents, and attempts to load from a specified file stream. @@ -122,6 +124,7 @@ namespace Jupiter * @return True if the file was successfully written to the drive, false otherwise. */ bool sync(const char *file); + bool sync(const Jupiter::ReadableString &file); /** * @brief Syncs data from the file to the drive. diff --git a/Jupiter/INIFile.cpp b/Jupiter/INIFile.cpp index d6659af..24ee397 100644 --- a/Jupiter/INIFile.cpp +++ b/Jupiter/INIFile.cpp @@ -288,6 +288,11 @@ unsigned int Jupiter::INIFile::readFile(const char *fileName) return total; } +unsigned int Jupiter::INIFile::readFile(const Jupiter::ReadableString &file) +{ + return Jupiter::INIFile::readFile(Jupiter::CStringS(file).c_str()); +} + unsigned int Jupiter::INIFile::reload() { Jupiter::CStringS fileName = Jupiter::INIFile::data_->fName; @@ -325,6 +330,11 @@ bool Jupiter::INIFile::sync(const char *fileName) return true; } +bool Jupiter::INIFile::sync(const Jupiter::ReadableString &file) +{ + return Jupiter::INIFile::sync(Jupiter::CStringS(file).c_str()); +} + bool Jupiter::INIFile::sync() { if (Jupiter::INIFile::data_->fName.size() == 0) return false; diff --git a/Jupiter/INIFile.h b/Jupiter/INIFile.h index 5f7d7cb..c4e7ae4 100644 --- a/Jupiter/INIFile.h +++ b/Jupiter/INIFile.h @@ -209,6 +209,7 @@ namespace Jupiter * @return The number of key-value pairs added on success, ERROR_INDICATOR (-1) otherwise. */ unsigned int readFile(const char *fileName); + unsigned int readFile(const Jupiter::ReadableString &file); /** * @brief Flushes all stored data and recollects from the last read file. @@ -224,6 +225,7 @@ namespace Jupiter * @return True on success, false otherwise. */ bool sync(const char *fileName); + bool sync(const Jupiter::ReadableString &file); /** * @brief Syncs data to the file that was last read from. diff --git a/Release/Jupiter.lib b/Release/Jupiter.lib index 3860012..f3a52e7 100644 Binary files a/Release/Jupiter.lib and b/Release/Jupiter.lib differ