ref: 3ae824b5b4c0f92a3ed3fe5a7274bbba6337e2ee
parent: 7d03bfc3f1cc2e871ea4efe94b4377bfec4ae253
author: Simon Howard <[email protected]>
date: Mon Oct 23 13:48:38 EDT 2006
Move MakeDirectory function into m_misc.c. Move configdir related code into m_misc.c. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 715
--- 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,64 +1129,7 @@
}
}
-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
//
// Chooses the directory used to store saved games.
@@ -1222,7 +1152,7 @@
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 @@
strcat(savegamedir, "/");
strcat(savegamedir, iwads[i].name);
strcat(savegamedir, "/");
- MakeDirectory(savegamedir);
+ M_MakeDirectory(savegamedir);
break;
}
}
@@ -1418,7 +1348,7 @@
// find which dir to use for config files
- SetConfigDir();
+ M_SetConfigDir();
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -255,7 +255,6 @@
//
// File handling stuff.
-extern char * configdir;
extern char * savegamedir;
extern char basedefault[1024];
extern FILE* debugfile;
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -109,9 +109,22 @@
return x;
}
+//
+// Create a directory
+//
+void M_MakeDirectory(char *path)
+{
+#ifdef _WIN32
+ mkdir(path);
+#else
+ mkdir(path, 0755);
+#endif
+}
+
+
//
// M_WriteFile
//
@@ -171,8 +184,12 @@
// DEFAULTS
//
-// locations of config files
+// Location where all configuration data is stored -
+// default.cfg, savegames, etc.
+char * configdir;
+
+
int usemouse = 1;
int usejoystick = 0;
@@ -593,6 +610,54 @@
LoadDefaultCollection(&doom_defaults);
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("");
+ }
+ }
+}
+
//
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -53,7 +53,11 @@
void M_SaveDefaults (void);
+void M_SetConfigDir(void);
+void M_MakeDirectory(char *dir);
+
+
int
M_DrawText
( int x,
@@ -61,5 +65,6 @@
boolean direct,
char* string );
+extern char *configdir;
#endif