Browse Source

ReadableString & now accepted in place of C-Style string.

release/0.19
JustinAJ 10 years ago
parent
commit
32a7ba9829
  1. 26
      Jupiter/File.cpp
  2. 3
      Jupiter/File.h
  3. 10
      Jupiter/INIFile.cpp
  4. 2
      Jupiter/INIFile.h
  5. BIN
      Release/Jupiter.lib

26
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++)

3
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.

10
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;

2
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.

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save