mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Extract method IStorage::GetBinaryPathAbsolute
This commit is contained in:
parent
a0df1ebfc0
commit
6e28ca6fe4
|
@ -4906,22 +4906,8 @@ int CClient::UdpConnectivity(int NetType)
|
|||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
void CClient::ShellRegister()
|
||||
{
|
||||
char aBinaryPath[IO_MAX_PATH_LENGTH];
|
||||
Storage()->GetBinaryPath(PLAT_CLIENT_EXEC, aBinaryPath, sizeof(aBinaryPath));
|
||||
char aFullPath[IO_MAX_PATH_LENGTH];
|
||||
if(fs_is_relative_path(aBinaryPath))
|
||||
{
|
||||
if(fs_getcwd(aFullPath, sizeof(aFullPath)))
|
||||
{
|
||||
str_append(aFullPath, "/", sizeof(aFullPath));
|
||||
str_append(aFullPath, aBinaryPath, sizeof(aFullPath));
|
||||
}
|
||||
else
|
||||
aFullPath[0] = '\0';
|
||||
}
|
||||
else
|
||||
str_copy(aFullPath, aBinaryPath);
|
||||
|
||||
Storage()->GetBinaryPathAbsolute(PLAT_CLIENT_EXEC, aFullPath, sizeof(aFullPath));
|
||||
if(!aFullPath[0])
|
||||
{
|
||||
dbg_msg("client", "Failed to register protocol and file extensions: could not determine absolute path");
|
||||
|
|
|
@ -677,6 +677,25 @@ public:
|
|||
return pBuffer;
|
||||
}
|
||||
|
||||
const char *GetBinaryPathAbsolute(const char *pFilename, char *pBuffer, unsigned BufferSize) override
|
||||
{
|
||||
char aBinaryPath[IO_MAX_PATH_LENGTH];
|
||||
GetBinaryPath(PLAT_CLIENT_EXEC, aBinaryPath, sizeof(aBinaryPath));
|
||||
if(fs_is_relative_path(aBinaryPath))
|
||||
{
|
||||
if(fs_getcwd(pBuffer, BufferSize))
|
||||
{
|
||||
str_append(pBuffer, "/", BufferSize);
|
||||
str_append(pBuffer, aBinaryPath, BufferSize);
|
||||
}
|
||||
else
|
||||
pBuffer[0] = '\0';
|
||||
}
|
||||
else
|
||||
str_copy(pBuffer, aBinaryPath, BufferSize);
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
static IStorage *Create(int StorageType, int NumArgs, const char **ppArguments)
|
||||
{
|
||||
CStorage *pStorage = new CStorage();
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
virtual bool RemoveBinaryFile(const char *pFilename) = 0;
|
||||
virtual bool RenameBinaryFile(const char *pOldFilename, const char *pNewFilename) = 0;
|
||||
virtual const char *GetBinaryPath(const char *pFilename, char *pBuffer, unsigned BufferSize) = 0;
|
||||
virtual const char *GetBinaryPathAbsolute(const char *pFilename, char *pBuffer, unsigned BufferSize) = 0;
|
||||
|
||||
static void StripPathAndExtension(const char *pFilename, char *pBuffer, int BufferSize);
|
||||
static const char *FormatTmpPath(char *aBuf, unsigned BufSize, const char *pPath);
|
||||
|
|
Loading…
Reference in a new issue