Pasaeta de cppcheck, ale
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <SDL2/SDL_stdinc.h> // for SDL_max
|
||||
#include <stddef.h> // for size_t
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Asset *Asset::asset_ = nullptr;
|
||||
@@ -42,8 +44,7 @@ void Asset::add(const std::string &file, AssetType type, bool required, bool abs
|
||||
ai.required = required;
|
||||
file_list_.push_back(ai);
|
||||
|
||||
const std::string file_name = file.substr(file.find_last_of("\\/") + 1);
|
||||
longest_name_ = SDL_max(longest_name_, file_name.size());
|
||||
longest_name_ = SDL_max(longest_name_, getFileName(file).size());
|
||||
}
|
||||
|
||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
||||
@@ -114,20 +115,12 @@ bool Asset::check() const
|
||||
// Comprueba que existe un fichero
|
||||
bool Asset::checkFile(const std::string &path) const
|
||||
{
|
||||
auto success = false;
|
||||
std::ifstream file(path);
|
||||
bool success = file.good();
|
||||
file.close();
|
||||
|
||||
// Comprueba si existe el fichero
|
||||
auto file = SDL_RWFromFile(path.c_str(), "rb");
|
||||
|
||||
if (file)
|
||||
{
|
||||
success = true;
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
|
||||
if (!success)
|
||||
printWithDots("Checking file : ", file_name, (success ? " [ OK ]" : " [ ERROR ]"));
|
||||
printWithDots("Checking file : ", getFileName(path), "[ ERROR ]");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user