Added proper Windows support.

I think this should be good, but I can't test it right now because
I don't have a Windows compiler handy at the moment. Will make sure
to do so before making a release.
This commit is contained in:
Julie Marchant 2019-05-27 00:28:04 -04:00
parent 79fbdc7aca
commit c0ca361da6
1 changed files with 8 additions and 5 deletions

View File

@ -22,7 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#ifndef _WIN32 #ifdef _WIN32
#include <Shlobj.h>
#else
#include <pwd.h> #include <pwd.h>
#endif #endif
@ -197,10 +199,11 @@ void engine_setupConfigDirectory()
char dir[PATH_MAX]; char dir[PATH_MAX];
#ifdef _WIN32 #ifdef _WIN32
// XXX: This is a bad design, but I just can't be bothered to learn if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &userHome) != S_OK)
// the Windows API so I can do this properly. If anyone wants to {
// make this point to the proper directory, be my guest! userHome = ".";
userHome = "."; engine_warn("Could not get appdata location; using the current working directory instead.");
}
#else #else
if ((userHome = getenv("HOME")) == NULL) if ((userHome = getenv("HOME")) == NULL)
userHome = getpwuid(getuid())->pw_dir; userHome = getpwuid(getuid())->pw_dir;