Estandaritzats els accessos a fitxers
This commit is contained in:
@@ -59,14 +59,13 @@ void ManageHiScoreTable::sort()
|
||||
}
|
||||
|
||||
// Carga la tabla con los datos de un fichero
|
||||
bool ManageHiScoreTable::loadFromFile(std::string filepath)
|
||||
bool ManageHiScoreTable::loadFromFile(std::string filePath)
|
||||
{
|
||||
clear();
|
||||
|
||||
bool success = true;
|
||||
const std::string p = filepath;
|
||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
SDL_RWops *file = SDL_RWFromFile(filePath.c_str(), "r+b");
|
||||
|
||||
if (file)
|
||||
{
|
||||
@@ -116,12 +115,11 @@ bool ManageHiScoreTable::loadFromFile(std::string filepath)
|
||||
}
|
||||
|
||||
// Guarda la tabla en un fichero
|
||||
bool ManageHiScoreTable::saveToFile(std::string filepath)
|
||||
bool ManageHiScoreTable::saveToFile(std::string filePath)
|
||||
{
|
||||
bool success = true;
|
||||
const std::string p = filepath;
|
||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "w+b");
|
||||
const std::string fileName = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
SDL_RWops *file = SDL_RWFromFile(filePath.c_str(), "w+b");
|
||||
|
||||
if (file)
|
||||
{
|
||||
@@ -135,7 +133,7 @@ bool ManageHiScoreTable::saveToFile(std::string filepath)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << "Writing file: " << filename.c_str() << std::endl;
|
||||
std::cout << "Writing file: " << fileName.c_str() << std::endl;
|
||||
#endif
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
@@ -143,7 +141,7 @@ bool ManageHiScoreTable::saveToFile(std::string filepath)
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
std::cout << "Error: Unable to save " << fileName.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
#endif
|
||||
}
|
||||
return success;
|
||||
|
||||
Reference in New Issue
Block a user