forked from teamnwah/openmw-tes3coop
[Server] Add DoesFileExist() script function
This commit is contained in:
parent
51fd937250
commit
980ddcb114
2 changed files with 17 additions and 0 deletions
|
@ -11,6 +11,11 @@ using namespace std;
|
|||
|
||||
static std::string tempFilename;
|
||||
|
||||
bool MiscellaneousFunctions::DoesFileExist(const char *filePath) noexcept
|
||||
{
|
||||
return boost::filesystem::exists(filePath);
|
||||
}
|
||||
|
||||
const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
|
||||
{
|
||||
if (!boost::filesystem::exists(folderPath)) return "invalid";
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../Types.hpp"
|
||||
|
||||
#define MISCELLANEOUSAPI \
|
||||
{"DoesFileExist", MiscellaneousFunctions::DoesFileExist},\
|
||||
{"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\
|
||||
\
|
||||
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
|
||||
|
@ -21,6 +22,17 @@ class MiscellaneousFunctions
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Check whether a certain file exists.
|
||||
*
|
||||
* This will be a case sensitive check on case sensitive filesystems.
|
||||
*
|
||||
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
|
||||
*
|
||||
* \return Whether the file exists or not.
|
||||
*/
|
||||
static bool DoesFileExist(const char *filePath) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the first filename in a folder that has a case insensitive match with the filename
|
||||
* argument.
|
||||
|
|
Loading…
Reference in a new issue