- fi = fopen(filename, "r");
- if (fi == NULL)
- {
- perror(filename);
- }
- lisp_stream_t stream;
- lisp_stream_init_file (&stream, fi);
- root_obj = lisp_read (&stream);
-
- if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR)
- {
- printf("World: Parse Error in file %s", filename);
- }
-
- lisp_object_t* cur = lisp_car(root_obj);
-
- if (!lisp_symbol_p (cur))
- {
- printf("World: Read error in %s",filename);
- }
-
- if (strcmp(lisp_symbol(cur), "supertux-level-subset") == 0)
- {
- parse(lisp_cdr(root_obj));
-
- }
-
- lisp_free(root_obj);
- fclose(fi);
-
- snprintf(str, 1024, "%s.png", filename);
- if(faccessible(str))
+ directory = filename;
+ }
+ else
+ {
+ filename = datadir + "/levels/" + subset + "/";
+ if (access(filename.c_str(), R_OK) == 0)
+ directory = filename;
+ else
+ std::cout << "Error: LevelSubset: couldn't find subset: " << subset << std::endl;
+ }
+
+ read_info_file(directory + "info");
+
+ if (levels.empty())
+ { // Level info file doesn't define any levels, so read the
+ // directory to see what we can find
+ std::set<std::string> files;
+
+ filename = st_dir + "/levels/" + subset + "/";
+ if(access(filename.c_str(), R_OK) == 0)