Skip to content

Commit

Permalink
get documents and tmp directory linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ink-pot-monkey committed Jul 23, 2021
1 parent fdb0102 commit bee3ee3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/SoyFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#if defined(TARGET_LINUX)
#include <filesystem>
#include <pwd.h>
#endif

#if defined(TARGET_LINUX)||defined(TARGET_ANDROID)
Expand Down Expand Up @@ -1258,14 +1259,26 @@ std::string Platform::GetAppResourcesDirectory()
#if !defined(TARGET_IOS)&&!defined(TARGET_OSX)
std::string Platform::GetDocumentsDirectory()
{
Soy_AssertTodo();
const char *homedir;

if ((homedir = getenv("HOME")) == NULL)
homedir = getpwuid(getuid())->pw_dir;

return homedir;
}
#endif

#if defined(TARGET_LINUX)
std::string Platform::GetTempDirectory()
{
return std::filesystem::temp_directory_path();
}
#else
std::string Platform::GetTempDirectory()
{
Soy_AssertTodo();
}
#endif

std::string Platform::GetCacheDirectory()
{
Expand Down

0 comments on commit bee3ee3

Please sign in to comment.