changed some platform-related preprocessor definition names
[rocksndiamonds.git] / src / libgame / setup.c
index 0382a4d7a2e53b315d4fe68d68e7770238bd1e5f..58e13b6bb87e0929e3d0a9a1a27bebdc37725696 100644 (file)
@@ -516,7 +516,7 @@ char *getProgramMainDataPath(char *command_filename, char *base_path)
      set the current working directory to the program package directory) */
   char *main_data_path = getBasePath(command_filename);
 
-#if defined(PLATFORM_MACOSX)
+#if defined(PLATFORM_MAC)
   if (strSuffix(main_data_path, MAC_APP_BINARY_SUBDIR))
   {
     char *main_data_path_old = main_data_path;
@@ -593,6 +593,34 @@ char *getProgramConfigFilename(char *command_filename)
   return config_filename_3;
 }
 
+static char *getPlatformConfigFilename(char *config_filename)
+{
+  static char *platform_config_filename = NULL;
+  static boolean initialized = FALSE;
+
+  if (!initialized)
+  {
+    char *config_basepath = getBasePath(config_filename);
+    char *config_basename = getBaseNameNoSuffix(config_filename);
+    char *config_filename_prefix = getPath2(config_basepath, config_basename);
+    char *platform_string_lower = getStringToLower(PLATFORM_STRING);
+    char *platform_suffix = getStringCat2("-", platform_string_lower);
+
+    platform_config_filename = getStringCat3(config_filename_prefix,
+                                            platform_suffix, ".conf");
+
+    checked_free(config_basepath);
+    checked_free(config_basename);
+    checked_free(config_filename_prefix);
+    checked_free(platform_string_lower);
+    checked_free(platform_suffix);
+
+    initialized = TRUE;
+  }
+
+  return platform_config_filename;
+}
+
 char *getTapeFilename(int nr)
 {
   static char *filename = NULL;
@@ -749,6 +777,11 @@ char *getDefaultSetupFilename(void)
   return program.config_filename;
 }
 
+char *getPlatformSetupFilename(void)
+{
+  return getPlatformConfigFilename(program.config_filename);
+}
+
 char *getEditorSetupFilename(void)
 {
   static char *filename = NULL;
@@ -1752,7 +1785,7 @@ void sortTreeInfo(TreeInfo **node_first)
 // some stuff from "files.c"
 // ============================================================================
 
-#if defined(PLATFORM_WIN32)
+#if defined(PLATFORM_WINDOWS)
 #ifndef S_IRGRP
 #define S_IRGRP S_IRUSR
 #endif
@@ -1777,7 +1810,7 @@ void sortTreeInfo(TreeInfo **node_first)
 #ifndef S_ISGID
 #define S_ISGID 0
 #endif
-#endif // PLATFORM_WIN32
+#endif // PLATFORM_WINDOWS
 
 // file permissions for newly written files
 #define MODE_R_ALL             (S_IRUSR | S_IRGRP | S_IROTH)
@@ -1801,7 +1834,7 @@ char *getHomeDir(void)
 {
   static char *dir = NULL;
 
-#if defined(PLATFORM_WIN32)
+#if defined(PLATFORM_WINDOWS)
   if (dir == NULL)
   {
     dir = checked_malloc(MAX_PATH + 1);
@@ -1835,7 +1868,7 @@ char *getPersonalDataDir(void)
 {
   static char *personal_data_dir = NULL;
 
-#if defined(PLATFORM_MACOSX)
+#if defined(PLATFORM_MAC)
   if (personal_data_dir == NULL)
     personal_data_dir = getPath2(getHomeDir(), "Documents");
 #else
@@ -1889,7 +1922,7 @@ static mode_t posix_umask(mode_t mask)
 
 static int posix_mkdir(const char *pathname, mode_t mode)
 {
-#if defined(PLATFORM_WIN32)
+#if defined(PLATFORM_WINDOWS)
   return mkdir(pathname);
 #else
   return mkdir(pathname, mode);