#include <dirent.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "platform.h"
if (!fileExists(dir))
if (posix_mkdir(dir, dir_mode) != 0)
- Error(ERR_WARN, "cannot create %s directory '%s'", text, dir);
+ Error(ERR_WARN, "cannot create %s directory '%s': %s",
+ text, dir, strerror(errno));
if (permission_class == PERMS_PUBLIC && !running_setgid)
chmod(dir, dir_mode);
struct dirent *dir_entry;
boolean valid_entry_found = FALSE;
+#if 1
+ Error(ERR_INFO, "looking for levels in '%s' ...", level_directory);
+#endif
+
if ((dir = opendir(level_directory)) == NULL)
{
Error(ERR_WARN, "cannot read level directory '%s'", level_directory);
+
return;
}
/* ~/.<program>/levelsetup.conf */
/* ----------------------------------------------------------------------- */
+ // check if the current level directory structure is available at this point
+ if (leveldir_current == NULL)
+ return;
+
char *filename = getPath2(getSetupDir(), LEVELSETUP_FILENAME);
char *level_subdir = leveldir_current->subdir;
FILE *file;
if (!(file = fopen(filename, MODE_WRITE)))
{
Error(ERR_WARN, "cannot write setup file '%s'", filename);
+
free(filename);
+
return;
}