 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file.
17 SDL_RWops *rw = SDL_RWFromFile(fileName.c_str(),
"rb");
18 Sint64 res_size = SDL_RWsize(rw);
19 char *res = (
char *)malloc(res_size + 1);
23 LOG(
LOG_ERROR) << stderr <<
"Couldn't open " << fileName.c_str();
26 Sint64 nb_read_total = 0, nb_read = 1;
29 while (nb_read_total < res_size && nb_read != 0)
31 nb_read = SDL_RWread(rw, buf, 1, (res_size - nb_read_total));
32 nb_read_total += nb_read;
36 res[nb_read_total] =
'\0';
40 if (nb_read_total != res_size)
43 LOG(
LOG_ERROR) <<
"ERROR loading file " << fileName << SDL_GetError();
52 LOG(
LOG_ERROR) <<
"fs::writeStringToFile() not implemented!";
57 LOG(
LOG_ERROR) <<
"fs::getDirectoryListing() not implemented!";
66 LOG(
LOG_ERROR) <<
"fs::writeStringToFileCompressed() not implemented!";
73 LOG(
LOG_ERROR) <<
"fs::createDreadCompressedFileAsStringirectory() not implemented!";
bool fileExists(const std::string &filePath)
Check if a file (or folder) exists.
void writeStringToFile(const std::string &fileName, const std::string &stringToWrite, bool binaryMode)
Write a string to a file.
std::vector< std::string > getSaveGamePaths()
Get all savegames in the savegame directory.
std::string readFileAsString(const std::string &fileName, bool binaryMode)
Read contents from a file as string.
std::string getBasePath()
Get base path (where Cytopia is being run)
void createDirectory(const std::string &dir)
std::vector< std::string > getDirectoryListing(const std::string &directory)
Get a directory listing of a given directory.
A generic error in Cytopia.
std::string readCompressedFileAsString(const std::string &fileName)
Read contents from a file as string.
void writeStringToFileCompressed(const std::string &fileName, const std::string &stringToWrite)
Write a string to a file and compress it.