Previous 15994 Revisions Next

r2880 Sunday 22nd June, 2008 at 18:56:41 UTC by Nathan Woods
Fixed new file manager bug when used on an empty slot, and removed some
vestigial code
[src/mess]filemngr.c image.c

src/mess/image.c
r2879r2880
578578{
579579   image_error_t err = IMAGE_ERROR_SUCCESS;
580580   astring *alloc_filename = NULL;
581   char *full_filename = NULL;
581582   char *new_name;
582583   char *new_dir;
583584   char *new_working_directory;
584585   int pos;
585586
587   /* get the full path */
588   if (osd_get_full_path(&full_filename, filename) == FILERR_NONE)
589      filename = full_filename;
590
586591   /* create the directory string */
587592   new_dir = filename ? image_strdup(image->dev, filename) : NULL;
588593   for (pos = strlen(new_dir); (pos > 0); pos--)
r2879r2880
631636done:
632637   if (alloc_filename != NULL)
633638      astring_free(alloc_filename);
639   if (full_filename != NULL)
640      free(full_filename);
634641   return err;
635642}
636643
r2879r2880
769776   specific path
770777-------------------------------------------------*/
771778
772static image_error_t load_image_by_path(image_slot_data *image, const char *software_path,
773   const game_driver *gamedrv, UINT32 open_flags, const char *path)
779static image_error_t load_image_by_path(image_slot_data *image, UINT32 open_flags, const char *path)
774780{
775781   file_error filerr = FILERR_NOT_FOUND;
776782   image_error_t err = IMAGE_ERROR_FILENOTFOUND;
777783   astring *full_path = NULL;
778784   const char *file_extension;
779785
780   /* assemble the path */
781   if (software_path)
782   {
783      full_path = astring_assemble_5(astring_alloc(), software_path, PATH_SEPARATOR, gamedrv->name, PATH_SEPARATOR, path);
784      path = astring_c(full_path);
785   }
786
787786   /* quick check to see if the file is a ZIP file */
788787   file_extension = strrchr(path, '.');
789788   if (!file_extension || mame_stricmp(file_extension, ".zip"))
r2879r2880
898897{
899898   running_machine *machine = image->machine;
900899   image_error_t err;
901   const char *software_path;
902   char *software_path_list = NULL;
903900   const void *buffer;
904   const game_driver *gamedrv;
905901   UINT32 open_plan[4];
906902   int i;
907903   image_slot_data *slot = find_image_slot(image);
r2879r2880
931927   /* attempt to open the file in various ways */
932928   for (i = 0; !slot->file && open_plan[i]; i++)
933929   {
934      software_path = software_path_list;
935      do
936      {
937         gamedrv = machine->gamedrv;
938         while(!is_loaded(slot) && (gamedrv != NULL))
939         {
940            /* open the file */
941            slot->err = load_image_by_path(slot, software_path, gamedrv, open_plan[i], path);
942            if (slot->err && (slot->err != IMAGE_ERROR_FILENOTFOUND))
943               goto done;
944
945            /* move on to the next driver */
946            gamedrv = mess_next_compatible_driver(gamedrv);
947         }
948
949         /* move on to the next entry in the software path; if we can */
950         if (software_path)
951            software_path += strlen(software_path) + 1;
952      }
953      while(!is_loaded(slot) && software_path && *software_path);
930      /* open the file */
931      slot->err = load_image_by_path(slot, open_plan[i], path);
932      if (slot->err && (slot->err != IMAGE_ERROR_FILENOTFOUND))
933         goto done;
954934   }
955935
956936   /* did we fail to find the file? */
r2879r2880
1006986   /* success! */
1007987
1008988done:
1009   if (software_path_list)
1010      free(software_path_list);
1011989   if (slot->err)
1012990      image_clear(slot);
1013991   slot->is_loading = 1;
src/mess/filemngr.c
r2879r2880
494494   {
495495      if (selected_absolute_index >= 0)
496496      {
497         file_error err;
498         char *full_path;
497         current_directory = astring_cpyc(astring_alloc(), image_working_directory(selected_device));
498         current_file = astring_cpyc(astring_alloc(),
499            image_exists(selected_device) ? image_basename(selected_device) : "");
499500
500         err = osd_get_full_path(&full_path, image_filename(selected_device));
501         if (err != FILERR_NONE)
502            return state;
503
504         current_directory = zippath_parent(astring_alloc(), full_path);
505         current_file = astring_cpyc(astring_alloc(), image_basename(selected_device));
506         free(full_path);
507
508501         memset(&fs_state, 0, sizeof(fs_state));
509502         return ui_menu_stack_push(menu_file_selector, fs_state.i);
510503      }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team