options.ro_base_directory = RO_BASE_PATH;
options.rw_base_directory = RW_BASE_PATH;
options.level_directory = RO_BASE_PATH "/" LEVELS_DIRECTORY;
+ options.graphics_directory = RO_BASE_PATH "/" GRAPHICS_DIRECTORY;
options.serveronly = FALSE;
options.network = FALSE;
options.verbose = FALSE;
" -d, --display machine:0 X server display\n"
" -b, --basepath directory alternative base directory\n"
" -l, --level directory alternative level directory\n"
- " -s, --serveronly only start network server\n"
+ " -g, --graphics directory alternative graphics directory\n"
" -n, --network network multiplayer game\n"
+ " -s, --serveronly only start network server\n"
" -v, --verbose verbose mode\n"
" --debug display debugging information\n",
program.command_basename);
if (option_arg == next_option)
options_left++;
}
+ else if (strncmp(option, "-graphics", option_len) == 0)
+ {
+ if (option_arg == NULL)
+ Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+
+ options.graphics_directory = option_arg;
+ if (option_arg == next_option)
+ options_left++;
+ }
else if (strncmp(option, "-network", option_len) == 0)
{
options.network = TRUE;
#ifndef S_IXOTH
#define S_IXOTH S_IXUSR
#endif
+#ifndef S_IRWXG
+#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+#endif
+#ifndef S_ISGID
+#define S_ISGID 0
+#endif
#endif /* PLATFORM_WIN32 */
/* file permissions for newly written files */
return getUserDataDir();
}
-void createDirectory(char *dir, char *text, int permission_class)
+static mode_t posix_umask(mode_t mask)
{
#if defined(PLATFORM_UNIX)
+ return umask(mask);
+#else
+ return 0;
+#endif
+}
+
+static int posix_mkdir(const char *pathname, mode_t mode)
+{
+#if defined(PLATFORM_WIN32)
+ return mkdir(pathname);
+#else
+ return mkdir(pathname, mode);
+#endif
+}
+
+void createDirectory(char *dir, char *text, int permission_class)
+{
/* leave "other" permissions in umask untouched, but ensure group parts
of USERDATA_DIR_MODE are not masked */
mode_t dir_mode = (permission_class == PERMS_PRIVATE ?
DIR_PERMS_PRIVATE : DIR_PERMS_PUBLIC);
- mode_t normal_umask = umask(0);
+ mode_t normal_umask = posix_umask(0);
mode_t group_umask = ~(dir_mode & S_IRWXG);
- umask(normal_umask & group_umask);
-#endif
+ posix_umask(normal_umask & group_umask);
if (access(dir, F_OK) != 0)
-#if defined(PLATFORM_WIN32)
- if (mkdir(dir) != 0)
-#else
- if (mkdir(dir, dir_mode) != 0)
-#endif
+ if (posix_mkdir(dir, dir_mode) != 0)
Error(ERR_WARN, "cannot create %s directory '%s'", text, dir);
-#if defined(PLATFORM_UNIX)
- umask(normal_umask); /* reset normal umask */
-#endif
+ posix_umask(normal_umask); /* reset normal umask */
}
void InitUserDataDirectory()