Made current file relative to engine directory
Former-commit-id: 7a664df265a1d1b7f9b3594e34418163cc023eda
This commit is contained in:
parent
8f593d56f4
commit
ce028e497a
|
|
@ -55,6 +55,7 @@ class NAZARA_API NzDirectory
|
|||
static bool Create(const NzString& dirPath, bool recursive = false);
|
||||
static bool Exists(const NzString& dirPath);
|
||||
static NzString GetCurrent();
|
||||
static const char* GetCurrentFileRelativeToEngine(const char* currentFile);
|
||||
static bool Remove(const NzString& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const NzString& dirPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
||||
#define NazaraAssert(a, err) if (!(a)) NzError(nzErrorType_AssertFailed, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraAssert(a, err) if (!(a)) NzError(nzErrorType_AssertFailed, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#else
|
||||
#define NazaraAssert(a, err)
|
||||
#endif
|
||||
|
||||
#define NazaraError(err) NzError(nzErrorType_Normal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraInternalError(err) NzError(nzErrorType_Internal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraWarning(err) NzError(nzErrorType_Warning, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||
#define NazaraError(err) NzError(nzErrorType_Normal, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraInternalError(err) NzError(nzErrorType_Internal, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraWarning(err) NzError(nzErrorType_Warning, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
|
||||
NAZARA_API void NzError(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function);
|
||||
NAZARA_API unsigned int NzGetLastSystemErrorCode();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Core/Win32/DirectoryImpl.hpp>
|
||||
|
|
@ -293,6 +294,30 @@ NzString NzDirectory::GetCurrent()
|
|||
return currentPath;
|
||||
}
|
||||
|
||||
const char* NzDirectory::GetCurrentFileRelativeToEngine(const char* currentFile)
|
||||
{
|
||||
///FIXME: Est-ce que cette méthode est au bon endroit ?
|
||||
static int offset = -1;
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
const char* directoryFile = __FILE__;
|
||||
const char* ptr = std::strstr(directoryFile, "NazaraEngine/src/Nazara/Core/Directory.cpp");
|
||||
if (ptr)
|
||||
offset = ptr - directoryFile;
|
||||
else
|
||||
{
|
||||
ptr = std::strstr(directoryFile, "NazaraEngine\\src\\Nazara\\Core\\Directory.cpp");
|
||||
if (ptr)
|
||||
offset = ptr - directoryFile;
|
||||
else
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ¤tFile[offset];
|
||||
}
|
||||
|
||||
bool NzDirectory::Remove(const NzString& dirPath, bool emptyDirectory)
|
||||
{
|
||||
if (dirPath.IsEmpty())
|
||||
|
|
|
|||
Loading…
Reference in New Issue