1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Move the function to test if a file exists in misc

This commit is contained in:
Mathieu Schroeter 2017-12-10 15:29:11 +01:00
parent 5c92d14c51
commit a058da17a3
4 changed files with 16 additions and 17 deletions

View File

@ -4394,7 +4394,7 @@ CEvent::StartMovie (const std::string & pFilename)
if (!m_bMovie)
return false;
if (!m_pMovie->IsExist (pFilename))
if (!FileExists (pFilename))
return false;
HideMouse (true);

View File

@ -155,3 +155,17 @@ AddUserPath (std::string & pFilename)
pFilename = path;
SDL_free (temp);
}
bool
FileExists (const std::string & filename)
{
const auto path = GetBaseDir () + filename;
FILE * file;
file = fopen (path.c_str (), "rb");
if (file == nullptr)
return false;
fclose (file);
return true;
}

View File

@ -37,6 +37,7 @@ std::string GetBaseDir ();
std::string GetShareDir ();
std::string GetLocale ();
extern void AddUserPath (std::string & pFilename);
bool FileExists (const std::string & filename);
template <typename... Args>
std::string

View File

@ -191,22 +191,6 @@ CMovie::GetEnable ()
return m_bEnable;
}
// Indique si un film existe.
bool
CMovie::IsExist (const std::string & pFilename)
{
const auto path = GetBaseDir () + pFilename;
FILE * file;
file = fopen (path.c_str (), "rb");
if (file == nullptr)
return false;
fclose (file);
return true;
}
// Montre un film avi.
bool