diff --git a/aegisub/libaegisub/Makefile b/aegisub/libaegisub/Makefile index daf685903..b7b85465a 100644 --- a/aegisub/libaegisub/Makefile +++ b/aegisub/libaegisub/Makefile @@ -17,7 +17,7 @@ LDFLAGS += -L../universalchardet -luniversalchardet endif common/charset_conv.o: CXXFLAGS += $(CFLAGS_ICONV) -unix/path.o: CXXFLAGS += -DDIR_DATA=\"$(P_DATA)\" -DDIR_DOC=\"$(P_DOC)\" +unix/path.o: CXXFLAGS += -DP_DATA=\"$(P_DATA)\" -DP_DOC=\"$(P_DOC)\" -DP_LOCALE=\"$(P_LOCALE)\" SRC = \ common/charset.cpp \ diff --git a/aegisub/libaegisub/unix/path.cpp b/aegisub/libaegisub/unix/path.cpp index 9e76ee08a..f863717ea 100644 --- a/aegisub/libaegisub/unix/path.cpp +++ b/aegisub/libaegisub/unix/path.cpp @@ -22,6 +22,9 @@ #include "config.h" #ifndef LAGI_PRE +#include +#include + #include #endif @@ -30,26 +33,40 @@ namespace agi { + +const std::string home() { + char *ehome; + ehome = getenv("HOME"); + if (ehome == NULL) { + //XXX: explode here. + } + std::string home(ehome); + free(ehome); + return home; +} + + const std::string Path::Data() { - return DIR_DATA; + return P_DATA; } const std::string Path::Doc() { - return DIR_DOC; + return P_DOC; } const std::string Path::User() { - return "~/"; + return home(); } const std::string Path::Locale() { - std::string tmp("~/.aegisub-"); - return tmp.append(AEGISUB_VERSION_DATA); + return P_LOCALE; } const std::string Path::Config() { - std::string tmp("~/.aegisub-"); - return tmp.append(AEGISUB_VERSION_DATA); + std::string tmp(home()); + tmp.append("/.aegisub-"); + tmp.append(AEGISUB_VERSION_DATA); + return tmp.append("/"); } const std::string Path::Temp() {