Skip to content

Commit

Permalink
Fix compile errors in platform specific Path implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Sep 2, 2023
1 parent bedf29d commit 331d55e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions sources/Platform/Android/AndroidPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ LLGL_EXPORT char GetSeparator()

LLGL_EXPORT UTF8String GetWorkingDir()
{
char path[PATH_MAX] = { 0 };
::getcwd(path, PATH_MAX);
return UTF8String{ path };
char path[4096] = { 0 };
return UTF8String{ ::getcwd(path, sizeof(path)) };
}

LLGL_EXPORT UTF8String GetAbsolutePath(const StringView& filename)
Expand Down
4 changes: 2 additions & 2 deletions sources/Platform/Linux/LinuxPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "../Path.h"
#include <unistd.h>
#include <linux/limits.h>


namespace LLGL
Expand All @@ -24,8 +25,7 @@ LLGL_EXPORT char GetSeparator()
LLGL_EXPORT UTF8String GetWorkingDir()
{
char path[PATH_MAX] = { 0 };
::getcwd(path, PATH_MAX);
return UTF8String{ path };
return UTF8String{ ::getcwd(path, sizeof(path)) };
}

LLGL_EXPORT UTF8String GetAbsolutePath(const StringView& filename)
Expand Down
6 changes: 3 additions & 3 deletions sources/Platform/Win32/Win32Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ LLGL_EXPORT char GetSeparator()
LLGL_EXPORT UTF8String GetWorkingDir()
{
const DWORD pathLen = ::GetCurrentDirectory(0, nullptr);
if (path > 0)
if (pathLen > 0)
{
/* Override content of string including the NUL-terminator, which is allowed since C++11 */
#ifdef UNICODE
std::wstring path;
#else
std::string path;
#endif
path.resize(static_cast<std::size_t>(path - 1));
::GetCurrentDirectory(static_cast<DWORD>(path.size()), &path[0]);
path.resize(static_cast<std::size_t>(pathLen - 1));
::GetCurrentDirectory(pathLen, &path[0]);
return path;
}
return "";
Expand Down

0 comments on commit 331d55e

Please sign in to comment.