forked from Mirrors/openclonk
Move GetRelativePath to C4Language
C4Language is the only consumer of GetRelativePath. It cannot handle arbitrarily sized paths, so discourage new code from using it by moving it to C4Language.cpp. Also remove the buffer size parameter which was always defaulted anyway and use template parameter deduction to always get the correct size.alut-include-path
parent
333cf9c4b6
commit
e3d6486f2a
|
@ -31,6 +31,17 @@
|
|||
#include "config/C4Config.h"
|
||||
#include "game/C4Game.h"
|
||||
|
||||
template<size_t iBufferSize>
|
||||
static bool GetRelativePath(const char *strPath, const char *strRelativeTo, char(&strBuffer)[iBufferSize])
|
||||
{
|
||||
// Specified path is relative to base path
|
||||
// Copy relative section
|
||||
const char *szCpy;
|
||||
SCopy(szCpy = GetRelativePathS(strPath, strRelativeTo), strBuffer, iBufferSize);
|
||||
// return whether it was made relative
|
||||
return szCpy != strPath;
|
||||
}
|
||||
|
||||
C4Language Languages;
|
||||
|
||||
C4Language::C4Language()
|
||||
|
|
|
@ -218,16 +218,6 @@ bool GetParentPath(const char *szFilename, StdStrBuf *outBuf)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GetRelativePath(const char *strPath, const char *strRelativeTo, char *strBuffer, int iBufferSize)
|
||||
{
|
||||
// Specified path is relative to base path
|
||||
// Copy relative section
|
||||
const char *szCpy;
|
||||
SCopy(szCpy=GetRelativePathS(strPath, strRelativeTo), strBuffer, iBufferSize);
|
||||
// return whether it was made relative
|
||||
return szCpy!=strPath;
|
||||
}
|
||||
|
||||
const char *GetRelativePathS(const char *strPath, const char *strRelativeTo)
|
||||
{
|
||||
// Specified path is relative to base path
|
||||
|
|
|
@ -54,7 +54,6 @@ bool TruncatePath(char *szPath);
|
|||
// szBuffer has to be of at least _MAX_PATH length.
|
||||
bool GetParentPath(const char *szFilename, char *szBuffer);
|
||||
bool GetParentPath(const char *szFilename, StdStrBuf *outBuf);
|
||||
bool GetRelativePath(const char *strPath, const char *strRelativeTo, char *strBuffer, int iBufferSize=_MAX_PATH);
|
||||
const char *GetRelativePathS(const char *strPath, const char *strRelativeTo);
|
||||
bool IsGlobalPath(const char *szPath);
|
||||
|
||||
|
|
Loading…
Reference in New Issue