Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
godlikepanos committed Aug 23, 2019
1 parent b8c9029 commit 5a2e3f0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/anki/core/App.cpp
Expand Up @@ -496,7 +496,7 @@ Error App::initDirs(const ConfigSet& cfg)
#if !ANKI_OS_ANDROID
// Settings path
StringAuto home(m_heapAlloc);
ANKI_CHECK(getHomeDirectory(m_heapAlloc, home));
ANKI_CHECK(getHomeDirectory(home));

m_settingsDir.sprintf(m_heapAlloc, "%s/.anki", &home[0]);

Expand Down
7 changes: 7 additions & 0 deletions src/anki/physics/Common.h
Expand Up @@ -16,6 +16,10 @@
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wfloat-conversion"
#endif
#if ANKI_COMPILER_MSVC
# pragma warning(push)
# pragma warning(disable : 4305)
#endif
#define BT_THREADSAFE 0
#define BT_NO_PROFILE 1
#include <btBulletCollisionCommon.h>
Expand All @@ -26,6 +30,9 @@
#if ANKI_COMPILER_GCC_COMPATIBLE
# pragma GCC diagnostic pop
#endif
#if ANKI_COMPILER_MSVC
# pragma warning(pop)
#endif

namespace anki
{
Expand Down
2 changes: 1 addition & 1 deletion src/anki/util/Filesystem.h
Expand Up @@ -45,7 +45,7 @@ ANKI_USE_RESULT Error createDirectory(const CString& dir);
/// Get the home directory.
/// Write the home directory to @a buff. The @a buffSize is the size of the @a buff. If the @buffSize is not enough the
/// function will throw an exception.
ANKI_USE_RESULT Error getHomeDirectory(GenericMemoryPoolAllocator<U8> alloc, String& out);
ANKI_USE_RESULT Error getHomeDirectory(StringAuto& out);
/// @}

} // end namespace anki
4 changes: 2 additions & 2 deletions src/anki/util/FilesystemPosix.cpp
Expand Up @@ -195,7 +195,7 @@ Error createDirectory(const CString& dir)
return err;
}

Error getHomeDirectory(GenericMemoryPoolAllocator<U8> alloc, String& out)
Error getHomeDirectory(StringAuto& out)
{
const char* home = getenv("HOME");
if(home == nullptr)
Expand All @@ -204,7 +204,7 @@ Error getHomeDirectory(GenericMemoryPoolAllocator<U8> alloc, String& out)
return Error::FUNCTION_FAILED;
}

out.create(alloc, home);
out.create(home);
return Error::NONE;
}

Expand Down
23 changes: 6 additions & 17 deletions src/anki/util/FilesystemWindows.cpp
Expand Up @@ -7,6 +7,7 @@
#include <anki/util/Assert.h>
#include <anki/util/Logger.h>
#include <windows.h>
#include <Shlobj.h>
#include <anki/util/CleanupWindows.h>

namespace anki
Expand Down Expand Up @@ -70,28 +71,16 @@ Error createDirectory(const CString& dir)
return err;
}

Error getHomeDirectory(GenericMemoryPoolAllocator<U8> alloc, String& out)
Error getHomeDirectory(StringAuto& out)
{
const char* homed = getenv("HOMEDRIVE");
const char* homep = getenv("HOMEPATH");

if(homed == nullptr || homep == nullptr)
char path[MAX_PATH];
if(SHGetFolderPath(NULL, CSIDL_PROFILE, nullptr, 0, path) != S_OK)
{
ANKI_UTIL_LOGE("HOME environment variables not set");
ANKI_UTIL_LOGE("SHGetFolderPath() failed");
return Error::FUNCTION_FAILED;
}

out.sprintf(alloc, "%s/%s", homed, homep);

// Convert to Unix path
for(char& c : out)
{
if(c == '\\')
{
c = '/';
}
}

out.create(path);
return Error::NONE;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/util/Filesystem.cpp
Expand Up @@ -58,7 +58,7 @@ ANKI_TEST(Util, HomeDir)
HeapAllocator<char> alloc(allocAligned, nullptr);
StringAuto out(alloc);

ANKI_TEST_EXPECT_NO_ERR(getHomeDirectory(alloc, out));
ANKI_TEST_EXPECT_NO_ERR(getHomeDirectory(out));
printf("home dir %s\n", &out[0]);
ANKI_TEST_EXPECT_GT(out.getLength(), 0);
}
Expand Down

0 comments on commit 5a2e3f0

Please sign in to comment.