summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-10-23 17:48:38 +0000
committerSimon Howard2006-10-23 17:48:38 +0000
commit3ae824b5b4c0f92a3ed3fe5a7274bbba6337e2ee (patch)
treece15758ef8d72f0a17fb8d04ac75bd96114f615a
parent7d03bfc3f1cc2e871ea4efe94b4377bfec4ae253 (diff)
downloadchocolate-doom-3ae824b5b4c0f92a3ed3fe5a7274bbba6337e2ee.tar.gz
chocolate-doom-3ae824b5b4c0f92a3ed3fe5a7274bbba6337e2ee.tar.bz2
chocolate-doom-3ae824b5b4c0f92a3ed3fe5a7274bbba6337e2ee.zip
Move MakeDirectory function into m_misc.c. Move configdir related code
into m_misc.c. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 715
-rw-r--r--src/d_main.c76
-rw-r--r--src/doomstat.h1
-rw-r--r--src/m_misc.c67
-rw-r--r--src/m_misc.h5
4 files changed, 74 insertions, 75 deletions
diff --git a/src/d_main.c b/src/d_main.c
index b4d77961..d9f7e997 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -38,14 +38,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
-#include <io.h>
-#else
-#include <sys/stat.h>
-#include <sys/types.h>
-#endif
-
-
#include "config.h"
#include "deh_main.h"
#include "doomdef.h"
@@ -102,11 +94,6 @@
//
void D_DoomLoop (void);
-// Location where all configuration data is stored -
-// default.cfg, savegames, etc.
-
-char * configdir;
-
// Location where savegames are stored
char * savegamedir;
@@ -1142,63 +1129,6 @@ void PrintDehackedBanners(void)
}
}
-static void MakeDirectory(char *path)
-{
-#ifdef _WIN32
- mkdir(path);
-#else
- mkdir(path, 0755);
-#endif
-}
-
-
-//
-// SetConfigDir:
-//
-// Sets the location of the configuration directory, where configuration
-// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
-//
-
-static void SetConfigDir(void)
-{
- char *homedir;
-
- homedir = getenv("HOME");
-
- if (homedir != NULL)
- {
- // put all configuration in a config directory off the
- // homedir
-
- configdir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
-
- sprintf(configdir, "%s/.%s/", homedir, PACKAGE_TARNAME);
-
- // make the directory if it doesnt already exist
-
- MakeDirectory(configdir);
-
-
- }
- else
- {
-#ifdef _WIN32
- // when given the -cdrom option, save config+savegames in
- // c:\doomdata. This only applies under Windows.
-
- if (M_CheckParm("-cdrom") > 0)
- {
- printf(D_CDROM);
- configdir = strdup("c:\\doomdata\\");
- }
- else
-#endif
- {
- configdir = strdup("");
- }
- }
-}
-
//
// SetSaveGameDir
//
@@ -1222,7 +1152,7 @@ static void SetSaveGameDir(void)
savegamedir = malloc(strlen(configdir) + 30);
sprintf(savegamedir, "%ssavegames", configdir);
- MakeDirectory(savegamedir);
+ M_MakeDirectory(savegamedir);
// Find what subdirectory to use for savegames
//
@@ -1243,7 +1173,7 @@ static void SetSaveGameDir(void)
strcat(savegamedir, "/");
strcat(savegamedir, iwads[i].name);
strcat(savegamedir, "/");
- MakeDirectory(savegamedir);
+ M_MakeDirectory(savegamedir);
break;
}
}
@@ -1418,7 +1348,7 @@ void D_DoomMain (void)
// find which dir to use for config files
- SetConfigDir();
+ M_SetConfigDir();
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
diff --git a/src/doomstat.h b/src/doomstat.h
index 7d2ba3f9..e49ee54f 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -255,7 +255,6 @@ extern int maxammo[NUMAMMO];
//
// File handling stuff.
-extern char * configdir;
extern char * savegamedir;
extern char basedefault[1024];
extern FILE* debugfile;
diff --git a/src/m_misc.c b/src/m_misc.c
index 90e97da6..9f346212 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -109,6 +109,19 @@ M_DrawText
return x;
}
+//
+// Create a directory
+//
+
+void M_MakeDirectory(char *path)
+{
+#ifdef _WIN32
+ mkdir(path);
+#else
+ mkdir(path, 0755);
+#endif
+}
+
@@ -171,7 +184,11 @@ int M_ReadFile(char const *name, byte **buffer)
// DEFAULTS
//
-// locations of config files
+// Location where all configuration data is stored -
+// default.cfg, savegames, etc.
+
+char * configdir;
+
int usemouse = 1;
int usejoystick = 0;
@@ -594,6 +611,54 @@ void M_LoadDefaults (void)
LoadDefaultCollection(&extra_defaults);
}
+//
+// SetConfigDir:
+//
+// Sets the location of the configuration directory, where configuration
+// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
+//
+
+void M_SetConfigDir(void)
+{
+ char *homedir;
+
+ homedir = getenv("HOME");
+
+ if (homedir != NULL)
+ {
+ // put all configuration in a config directory off the
+ // homedir
+
+ configdir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
+
+ sprintf(configdir, "%s/.%s/", homedir, PACKAGE_TARNAME);
+
+ // make the directory if it doesnt already exist
+
+ M_MakeDirectory(configdir);
+ }
+ else
+ {
+#ifdef _WIN32
+ // when given the -cdrom option, save config+savegames in
+ // c:\doomdata. This only applies under Windows.
+
+ if (M_CheckParm("-cdrom") > 0)
+ {
+ printf(D_CDROM);
+ configdir = strdup("c:\\doomdata\\");
+
+ M_MakeDirectory(configdir);
+ }
+ else
+#endif
+ {
+ configdir = strdup("");
+ }
+ }
+}
+
+
//
// SCREEN SHOTS
diff --git a/src/m_misc.h b/src/m_misc.h
index bbd4f269..2258ec78 100644
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -53,6 +53,10 @@ void M_LoadDefaults (void);
void M_SaveDefaults (void);
+void M_SetConfigDir(void);
+
+void M_MakeDirectory(char *dir);
+
int
M_DrawText
@@ -61,5 +65,6 @@ M_DrawText
boolean direct,
char* string );
+extern char *configdir;
#endif