#if PLATFORM_UNIX
#include <unistd.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <assert.h>
typedef long long __int64;
typedef __int64 LARGE_INTEGER;
if (homedir == NULL)
homedir = "."; // oh well.
+#if (defined(__APPLE__) && defined(__MACH__))
+ const char *PREFPATHNAME = "Library/Application Support/Lugaru";
+#else
const char *PREFPATHNAME = ".lugaru";
+#endif
size_t len = strlen(homedir) + strlen(PREFPATHNAME) + 2;
prefpath = new char[len];
snprintf(prefpath, len, "%s/%s", homedir, PREFPATHNAME);
snprintf(prefpathfile, len, "%s/%s", prefpath, buf);
int rc = locateCorrectCase(prefpathfile, iswriting); /* favor prefpath. */
- if (rc == 0) // found?
+ if ( (rc == 0) || ((rc == -1) && (iswriting)) ) // found or create?
strcpy(buf, prefpathfile);
else if ((rc < 0) && (!iswriting)) /* not writing? Try game dir... */
rc = locateCorrectCase(buf, iswriting);