diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp index 3127a14c9..669f18380 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -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"; diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp index d5193fa24..2d5a02b9b 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -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.