Saving user data in "%APPDATA%/Application Data" on windows.
Some cleanups. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@503 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
0.2:
|
||||
- Saving user data in "%APPDATA%/Application Data" on windows - SvdB
|
||||
- Melnorme comm fix, from TD.
|
||||
- Planet scan font character fixes (micro.fon), from fOSSiL
|
||||
- Temporary files are deleted on exit. - SvdB
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
# define _NO_PROTO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
#ifndef HAVE_GETOPT_H
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETOPT_H
|
||||
#include "getopt.h"
|
||||
|
||||
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_CONFIG_H" /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_OPENAL" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_OPENAL" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_CONFIG_H" /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_OPENAL" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_OPENAL" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#define CONTENTDIR "../content"
|
||||
|
||||
/* Directory where game data will be stored */
|
||||
#define USERDIR "../userdata/"
|
||||
//#define USERDIR "../userdata/"
|
||||
#define USERDIR "%APPDATA%/uqm/"
|
||||
|
||||
/* Directory where supermelee teams will be stored */
|
||||
#define MELEEDIR USERDIR "teams/"
|
||||
|
||||
+1
-10
@@ -26,21 +26,12 @@
|
||||
#include "compiler.h"
|
||||
#include "options.h"
|
||||
#include "file.h"
|
||||
#include "config.h"
|
||||
|
||||
int optWhichMusic = MUSIC_3DO;
|
||||
char *configDir, *saveDir, *meleeDir;
|
||||
BOOLEAN optSubtitles = TRUE;
|
||||
|
||||
BOOLEAN FileExists (const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
if ((fp = fopen (filename, "rb")) == NULL)
|
||||
return FALSE;
|
||||
|
||||
fclose (fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
prepareConfigDir (void) {
|
||||
configDir = malloc (PATH_MAX - 13);
|
||||
|
||||
@@ -35,8 +35,6 @@ extern int optWhichMusic;
|
||||
|
||||
extern BOOLEAN optSubtitles;
|
||||
|
||||
BOOLEAN FileExists (const char *filename);
|
||||
|
||||
extern char *configDir;
|
||||
extern char *meleeDir;
|
||||
extern char *saveDir;
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
#ifndef _COMPILER_H
|
||||
#define _COMPILER_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
typedef BYTE *PBYTE;
|
||||
typedef unsigned char UBYTE;
|
||||
|
||||
@@ -38,13 +38,18 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
// for BOOLEAN
|
||||
#include "compiler.h"
|
||||
|
||||
void initTempDir (void);
|
||||
void unInitTempDir (void);
|
||||
char *tempFilePath (const char *filename);
|
||||
int mkdirhier (const char *path);
|
||||
const char *getHomeDir (void);
|
||||
int createDirectory(const char *dir, int mode);
|
||||
int expandPath(char *dest, size_t len, const char *src);
|
||||
int createDirectory (const char *dir, int mode);
|
||||
int expandPath (char *dest, size_t len, const char *src);
|
||||
BOOLEAN fileExists (const char *name);
|
||||
int getUserDataDir (char *dir, size_t len);
|
||||
|
||||
#endif /* _FILE_H */
|
||||
|
||||
|
||||
@@ -21,15 +21,33 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include "port.h"
|
||||
#include "config.h"
|
||||
#include "filintrn.h"
|
||||
#include "compiler.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# include <direct.h>
|
||||
|
||||
// this would lead to conflicts
|
||||
//# include <shlobj.h>
|
||||
typedef void *HWND;
|
||||
typedef void *HANDLE;
|
||||
typedef char *LPTSTR;
|
||||
typedef long HRESULT;
|
||||
#define SUCCEEDED(Status) ((HRESULT) (Status) >= 0)
|
||||
HRESULT __stdcall SHGetFolderPathA (HWND hwndOwner, int nFolder,
|
||||
HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);
|
||||
#define SHGetFolderPath SHGetFolderPathA
|
||||
#define CSIDL_APPDATA 0x001a // <user name>\Application Data
|
||||
#define CSIDL_FLAG_CREATE 0x8000
|
||||
// combine with CSIDL_ value to force folder creation in
|
||||
// SHGetFolderPath()
|
||||
#endif
|
||||
|
||||
int
|
||||
createDirectory(const char *dir, int mode) {
|
||||
createDirectory(const char *dir, int mode)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return mkdir (dir);
|
||||
#else
|
||||
@@ -41,7 +59,8 @@ createDirectory(const char *dir, int mode) {
|
||||
// returns 0 on success, -1 on failure.
|
||||
// on failure, some parts may still have been created.
|
||||
int
|
||||
mkdirhier (const char *path) {
|
||||
mkdirhier (const char *path)
|
||||
{
|
||||
char *buf; // buffer
|
||||
char *ptr; // end of the string in buf
|
||||
const char *pathstart; // start of a component of path
|
||||
@@ -67,7 +86,8 @@ mkdirhier (const char *path) {
|
||||
}
|
||||
|
||||
// walk through the path as long as the components exist
|
||||
while (1) {
|
||||
while (1)
|
||||
{
|
||||
pathend = strchr (pathstart, '/');
|
||||
if (pathend == NULL)
|
||||
pathend = path + len;
|
||||
@@ -75,8 +95,10 @@ mkdirhier (const char *path) {
|
||||
ptr += pathend - pathstart;
|
||||
*ptr = '\0';
|
||||
|
||||
if (stat (buf, &statbuf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
if (stat (buf, &statbuf) == -1)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
fprintf (stderr, "Can't stat %s: %s\n", buf,
|
||||
strerror (errno));
|
||||
return -1;
|
||||
@@ -99,8 +121,10 @@ mkdirhier (const char *path) {
|
||||
}
|
||||
|
||||
// create all components left
|
||||
while (1) {
|
||||
if (createDirectory (buf, 0777) == -1) {
|
||||
while (1)
|
||||
{
|
||||
if (createDirectory (buf, 0777) == -1)
|
||||
{
|
||||
fprintf (stderr, "Error: Can't create %s: %s\n", buf,
|
||||
strerror (errno));
|
||||
return -1;
|
||||
@@ -133,15 +157,28 @@ mkdirhier (const char *path) {
|
||||
// Get the user's home dir
|
||||
// returns a pointer to a static buffer
|
||||
const char *
|
||||
getHomeDir(void) {
|
||||
getHomeDir (void)
|
||||
{
|
||||
return getenv ("HOME");
|
||||
}
|
||||
|
||||
// Expand ~/ in a path, and replaces \ by / on Windows.
|
||||
// Environment variable parsing could be added here if we need it.
|
||||
int
|
||||
expandPath(char *dest, size_t len, const char *src) {
|
||||
size_t srclen;
|
||||
expandPath (char *dest, size_t len, const char *src)
|
||||
{
|
||||
const char *destend;
|
||||
|
||||
srclen = strlen (src);
|
||||
#define CHECKLEN(n) \
|
||||
if (dest + (n) > destend) \
|
||||
{ \
|
||||
errno = ENAMETOOLONG; \
|
||||
return -1; \
|
||||
} \
|
||||
else \
|
||||
(void) 0
|
||||
|
||||
destend = dest + len;
|
||||
if (src[0] == '~')
|
||||
{
|
||||
const char *home;
|
||||
@@ -161,39 +198,132 @@ expandPath(char *dest, size_t len, const char *src) {
|
||||
}
|
||||
homelen = strlen (home);
|
||||
|
||||
if (homelen + srclen > len)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, home, homelen);
|
||||
CHECKLEN (homelen);
|
||||
memcpy (dest, home, homelen);
|
||||
dest += homelen;
|
||||
src++; /* skip the ~ */
|
||||
} else {
|
||||
if (strlen (src) >= len)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
/* Replaces backslashes in path by slashes. */
|
||||
while (*src != '\0')
|
||||
{
|
||||
if (*src == '\\')
|
||||
switch (*src)
|
||||
{
|
||||
#ifdef WIN32
|
||||
case '\\':
|
||||
/* Replaces backslashes in path by slashes in Windows. */
|
||||
CHECKLEN(1);
|
||||
*(dest++) = '/';
|
||||
src++;
|
||||
break;
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
case '%':
|
||||
{
|
||||
/* Environment variable substitution in Windows */
|
||||
const char *end; // end of env var name in src
|
||||
const char *envVar;
|
||||
char *envName;
|
||||
size_t envNameLen, envVarLen;
|
||||
|
||||
src++;
|
||||
end = strchr (src, '%');
|
||||
if (end == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
||||
envNameLen = end - src;
|
||||
envName = malloc (envNameLen + 1);
|
||||
memcpy (envName, src, envNameLen + 1);
|
||||
envName[envNameLen] = '\0';
|
||||
envVar = getenv (envName);
|
||||
free (envName);
|
||||
|
||||
if (envVar == NULL)
|
||||
{
|
||||
#if 1
|
||||
if (strncmp (src, "APPDATA", envNameLen) == 0)
|
||||
{
|
||||
// fallback for when the APPDATA env var is not set
|
||||
if (getUserDataDir (dest, destend - dest) == -1)
|
||||
return -1;
|
||||
dest += strlen (dest);
|
||||
src = end + 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
// Substitute an empty string
|
||||
src = end + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
envVarLen = strlen (envVar);
|
||||
CHECKLEN (envVarLen);
|
||||
strcpy (dest, envVar);
|
||||
dest += envVarLen;
|
||||
src = end + 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
case '$':
|
||||
/* Environment variable substitution for Unix */
|
||||
// not implemented
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
CHECKLEN(1);
|
||||
*(dest++) = *(src++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
#else
|
||||
strcpy(dest, src);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns 0 on success, and fills dir with the path to the dir where there
|
||||
// user data is stored.
|
||||
// return -1 on error, and sets errno.
|
||||
int
|
||||
getUserDataDir (char *dir, size_t len)
|
||||
{
|
||||
#ifdef WIN32
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (!SUCCEEDED (SHGetFolderPath(NULL,
|
||||
CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, buf)))
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strlen (buf) >= len)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy (dir, buf);
|
||||
return 0;
|
||||
#else
|
||||
const char *homeDir;
|
||||
homeDir = getHomeDir();
|
||||
|
||||
if (strlen (homeDir) >= len)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy (dir, homeDir);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
fileExists (const char *name)
|
||||
{
|
||||
return access (name, F_OK) == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,5 @@
|
||||
|
||||
#include "../file.h"
|
||||
|
||||
void CreateDirectory (const char *dir, int mode);
|
||||
void RemoveTempDir (void);
|
||||
|
||||
#endif /* _FILEINTRN_H */
|
||||
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
MIKMODAPI extern struct MDRIVER drv_openal;
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
void MikMod_RegisterAllLoaders_internal(void)
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
/* Same as malloc, but sets error variable _mm_error when fails */
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
CHAR *_mm_errmsg[MMERR_MAX+1] =
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef SUNOS
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
@@ -32,10 +32,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
UWORD npertab[7*OCTAVE]={
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mikmod_internals.h"
|
||||
|
||||
static int sl_rlength;
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -37,10 +37,6 @@
|
||||
|
||||
#ifdef SOUNDMODULE_OPENAL
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ _GetMusicData (FILE *fp, DWORD length)
|
||||
|
||||
strcpy (threedoname, filename);
|
||||
strcpy (&threedoname[strlen (threedoname)-3], "ogg");
|
||||
if (FileExists (threedoname))
|
||||
if (fileExists (threedoname))
|
||||
{
|
||||
strcpy (filename, threedoname);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ _GetMusicData (FILE *fp, DWORD length)
|
||||
|
||||
strcpy (threedoname, filename);
|
||||
strcpy (&threedoname[strlen (threedoname)-3], "ogg");
|
||||
if (FileExists (threedoname))
|
||||
if (fileExists (threedoname))
|
||||
{
|
||||
strcpy (filename, threedoname);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ extern int ScreenHeight;
|
||||
#define SIS_SCREEN_WIDTH (SPACE_WIDTH - 14)
|
||||
#define SIS_SCREEN_HEIGHT (SPACE_HEIGHT - 13)
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "../port.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
+4
-7
@@ -22,9 +22,6 @@
|
||||
#ifdef WIN32
|
||||
# include <direct.h>
|
||||
#endif
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
@@ -50,11 +47,11 @@ CDToContentDir (char *contentdir)
|
||||
{
|
||||
const char *testfile = "starcon.txt";
|
||||
|
||||
if (!FileExists (testfile))
|
||||
if (!fileExists (testfile))
|
||||
{
|
||||
if ((chdir (contentdir) || !FileExists (testfile)) &&
|
||||
(chdir ("content") || !FileExists (testfile)) &&
|
||||
(chdir ("../../content") || !FileExists (testfile))) {
|
||||
if ((chdir (contentdir) || !fileExists (testfile)) &&
|
||||
(chdir ("content") || !fileExists (testfile)) &&
|
||||
(chdir ("../../content") || !fileExists (testfile))) {
|
||||
fprintf(stderr, "Fatal error: content not available, running from wrong dir?\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user