+ artwork_new->name = getStringCopy(artwork_new->filename);
+
+ artwork_new->name_short = getStringCopy(artwork_new->name);
+ artwork_new->name_sorting = getStringCopy(artwork_new->name);
+ }
+
+ if (node_parent == NULL) /* top level group */
+ {
+ artwork_new->basepath = base_directory;
+ artwork_new->fullpath = artwork_new->filename;
+ }
+ else /* sub level group */
+ {
+ artwork_new->basepath = node_parent->basepath;
+ artwork_new->fullpath = getPath2(node_parent->fullpath, directory_name);
+ }
+
+ check_dir = (type == TREE_TYPE_GRAPHICS_DIR ? options.graphics_directory :
+ type == TREE_TYPE_SOUNDS_DIR ? options.sounds_directory :
+ type == TREE_TYPE_MUSIC_DIR ? options.music_directory : "");
+ artwork_new->user_defined =
+ (artwork_new->basepath == check_dir ? FALSE : TRUE);
+
+#if 0
+ artwork_new->color = LEVELCOLOR(artwork_new);
+ artwork_new->class_desc = getLevelClassDescription(artwork_new);
+#endif
+
+ pushTreeInfo(node_first, artwork_new);
+
+ freeSetupFileList(setup_file_list);
+
+ free(directory_path);
+ free(filename);
+
+ return TRUE;
+}
+
+static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first,
+ TreeInfo *node_parent,
+ char *base_directory, int type)
+{
+ DIR *dir;
+ struct dirent *dir_entry;
+ boolean valid_entry_found = FALSE;
+
+ if ((dir = opendir(base_directory)) == NULL)
+ {
+ if ((type == TREE_TYPE_GRAPHICS_DIR &&
+ base_directory == options.graphics_directory) ||
+ (type == TREE_TYPE_SOUNDS_DIR &&
+ base_directory == options.sounds_directory) ||
+ (type == TREE_TYPE_MUSIC_DIR &&
+ base_directory == options.music_directory))
+ Error(ERR_WARN, "cannot read directory '%s'", base_directory);
+ return;
+ }
+
+ while ((dir_entry = readdir(dir)) != NULL) /* loop until last dir entry */
+ {
+ struct stat file_status;
+ char *directory_name = dir_entry->d_name;
+ char *directory_path = getPath2(base_directory, directory_name);
+
+ /* skip entries for current and parent directory */
+ if (strcmp(directory_name, ".") == 0 ||
+ strcmp(directory_name, "..") == 0)
+ {
+ free(directory_path);
+ continue;
+ }
+
+ /* find out if directory entry is itself a directory */
+ if (stat(directory_path, &file_status) != 0 || /* cannot stat file */
+ (file_status.st_mode & S_IFMT) != S_IFDIR) /* not a directory */
+ {
+ free(directory_path);
+ continue;
+ }