Updated linux build - moved getpwuid/etc. to SysInfo.

master
kts 2015-03-05 18:45:22 -08:00
parent d4ea6ce4b0
commit b3f9d3d0c8
3 changed files with 16 additions and 5 deletions

View File

@ -14,7 +14,7 @@ CXXFLAGS+=$(DEBUG) -Wall `sdl2-config --cflags` -I../../src -I../../src/states -
LDFLAGS+= -Wall -L../../../sdl/$(LIB_DIR) -Wl,-rpath=$(LIB_DIR)/ -lSDL2 -lSDL2_image -lpthread -Wl,--no-undefined -lm -ldl -pthread -lrt -Wl,-Bstatic -lGLEW -Wl,-Bdynamic -lGL
VPATH=../../src
BINARY=RtB$(BITS)
OBJ=main.o Asset.o AssetCache.o AssetManager.o Core.o fio.o checksum.o Log.o Quat.o Mat4.o Vec.o Mesh.o Texture.o Program.o RenderScene.o RenderSet.o RenderObject.o RenderCamera.o RenderView.o states/TestState.o states/MenuState.o Gui.o gui/GuiElement.o
OBJ=main.o Asset.o AssetCache.o AssetManager.o Core.o fio.o checksum.o Log.o Quat.o Mat4.o Vec.o Mesh.o Texture.o Program.o RenderScene.o RenderSet.o RenderObject.o RenderCamera.o RenderView.o states/TestState.o states/MenuState.o SysInfo.o Gui.o gui/GuiElement.o gui/GuiButton.o gui/GuiList.o
OBJ_DIR=obj
$(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJ))

View File

@ -150,11 +150,8 @@ int Core::initSystem() {
#elif _WIN32
asset_manager->addCache(new AssetCache("data"));
#else // assume lunix
char *path = getenv("HOME");
if (path == NULL) path = getpwuid(getuid())->pw_dir;
char user_dir[PATH_MAX];
snprintf(user_dir, PATH_MAX, "%s/RtB", path);
struct stat dir_check = {0};
char *user_dir = (char*)sysinfo.user_dir.c_str();
if (stat(user_dir, &dir_check) == -1) {
mkdir(user_dir, 0700);
}

View File

@ -4,6 +4,13 @@
#include <CoreServices/CoreServices.h>
#include <sys/types.h>
#include <unistd.h>
#elif defined(_WIN32)
#else
#include <stdio.h> //snprintf
#include <stdlib.h> // getenv
#include <unistd.h> // getuid
#include <sys/types.h>
#include <pwd.h> // getpwuid
#endif
@ -22,6 +29,13 @@ SysInfo::SysInfo() {
char path_dir[PATH_MAX];
snprintf(path_dir, PATH_MAX, "%s/RtB", path);
user_dir.assign(path_dir);
#elif defined(_WIN32)
#elif !defined(__ANDROID__)
char *path = getenv("HOME");
if (path == NULL) path = getpwuid(getuid())->pw_dir;
char path_dir[1024];
snprintf(path_dir, 1024, "%s/RtB", path);
user_dir.assign(path_dir);
#endif
}
SysInfo::~SysInfo() {