Estandaritzats els accessos a fitxers
This commit is contained in:
@@ -94,7 +94,7 @@ bool loadOptionsFile(std::string filePath)
|
||||
bool success = true;
|
||||
|
||||
// Variables para manejar el fichero
|
||||
std::string line;
|
||||
const std::string fileName = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::ifstream file(filePath);
|
||||
|
||||
// Si el fichero se puede abrir
|
||||
@@ -103,8 +103,9 @@ bool loadOptionsFile(std::string filePath)
|
||||
// Procesa el fichero linea a linea
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Reading file: " << filePath << std::endl;
|
||||
std::cout << "Reading file: " << fileName << std::endl;
|
||||
}
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Comprueba que la linea no sea un comentario
|
||||
@@ -117,7 +118,7 @@ bool loadOptionsFile(std::string filePath)
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Warning: file " << filePath << std::endl;
|
||||
std::cout << "Warning: file " << fileName << std::endl;
|
||||
std::cout << "Unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||
}
|
||||
success = false;
|
||||
@@ -160,21 +161,21 @@ bool loadOptionsFile(std::string filePath)
|
||||
// Guarda el fichero de configuración
|
||||
bool saveOptionsFile(std::string filePath)
|
||||
{
|
||||
const std::string filename = filePath;
|
||||
const std::string fileName = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::ofstream file(filePath);
|
||||
|
||||
if (!file.good())
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << filename << " can't be opened" << std::endl;
|
||||
std::cout << fileName << " can't be opened" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Writing file: " << filename << std::endl;
|
||||
std::cout << "Writing file: " << fileName << std::endl;
|
||||
}
|
||||
|
||||
// Opciones de video
|
||||
|
||||
Reference in New Issue
Block a user