added new utility to check if a file exists on system.
This commit is contained in:
@@ -119,3 +119,4 @@ u32 ramAvailable(void);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool FileExists(const string& strFilename);
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Subtypes.h"
|
#include "Subtypes.h"
|
||||||
#include "WResourceManager.h"
|
#include "WResourceManager.h"
|
||||||
#include "WFont.h"
|
#include "WFont.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace wagic
|
namespace wagic
|
||||||
{
|
{
|
||||||
@@ -297,3 +298,28 @@ std::string wordWrap(const std::string& sentence, float width, int fontId)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FileExists(const string& strFilename) {
|
||||||
|
struct stat stFileInfo;
|
||||||
|
bool blnReturn;
|
||||||
|
int intStat;
|
||||||
|
|
||||||
|
// Attempt to get the file attributes
|
||||||
|
intStat = stat(strFilename.c_str(),&stFileInfo);
|
||||||
|
if(intStat == 0) {
|
||||||
|
// We were able to get the file attributes
|
||||||
|
// so the file obviously exists.
|
||||||
|
blnReturn = true;
|
||||||
|
} else {
|
||||||
|
// We were not able to get the file attributes.
|
||||||
|
// This may mean that we don't have permission to
|
||||||
|
// access the folder which contains this file. If you
|
||||||
|
// need to do that level of checking, lookup the
|
||||||
|
// return values of stat which will give you
|
||||||
|
// more details on why stat failed.
|
||||||
|
blnReturn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(blnReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user