1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-07-05 18:51:34 +00:00

[Server] Add DoesFileExist() script function

This commit is contained in:
David Cernat 2018-05-04 03:09:54 +03:00
parent 51fd937250
commit 980ddcb114
2 changed files with 17 additions and 0 deletions

View file

@ -11,6 +11,11 @@ using namespace std;
static std::string tempFilename; 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 const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
{ {
if (!boost::filesystem::exists(folderPath)) return "invalid"; if (!boost::filesystem::exists(folderPath)) return "invalid";

View file

@ -4,6 +4,7 @@
#include "../Types.hpp" #include "../Types.hpp"
#define MISCELLANEOUSAPI \ #define MISCELLANEOUSAPI \
{"DoesFileExist", MiscellaneousFunctions::DoesFileExist},\
{"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\ {"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\
\ \
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\ {"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
@ -21,6 +22,17 @@ class MiscellaneousFunctions
{ {
public: 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 * \brief Get the first filename in a folder that has a case insensitive match with the filename
* argument. * argument.