]> wimlib.net Git - wimlib/blobdiff - src/wim.c
add_image.c: Add debugging statements for branch attachment
[wimlib] / src / wim.c
index b52a28d99c265cbf79b0ff1de3642dd9216eadc0..bd31c5b3ea9d1e1f1ee9e6ef262e502586988a5c 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -3,7 +3,7 @@
  */
 
 /*
- * Copyright (C) 2012 Eric Biggers
+ * Copyright (C) 2012, 2013 Eric Biggers
  *
  * wimlib - Library for working with WIM files
  *
@@ -204,6 +204,7 @@ WIMLIBAPI int wimlib_get_num_images(const WIMStruct *w)
 int select_wim_image(WIMStruct *w, int image)
 {
        struct wim_image_metadata *imd;
+       int ret;
 
        DEBUG("Selecting image %d", image);
 
@@ -233,20 +234,21 @@ int select_wim_image(WIMStruct *w, int image)
                        INIT_HLIST_HEAD(&imd->inode_list);
                }
        }
-
        w->current_image = image;
-       imd = wim_get_current_image_metadata(w);
-
+       imd = &w->image_metadata[image - 1];
        if (imd->root_dentry) {
-               return 0;
+               ret = 0;
        } else {
                #ifdef ENABLE_DEBUG
                DEBUG("Reading metadata resource specified by the following "
                      "lookup table entry:");
-               print_lookup_table_entry(imd->metadata_lte);
+               print_lookup_table_entry(imd->metadata_lte, stdout);
                #endif
-               return read_metadata_resource(w, imd);
+               ret = read_metadata_resource(w, imd);
+               if (ret)
+                       w->current_image = WIMLIB_NO_IMAGE;
        }
+       return ret;
 }
 
 
@@ -597,7 +599,7 @@ void destroy_image_metadata(struct wim_image_metadata *imd,
  * closes all files associated with the WIMStruct.  */
 WIMLIBAPI void wimlib_free(WIMStruct *w)
 {
-       DEBUG2("Freeing WIMStruct");
+       DEBUG("Freeing WIMStruct");
 
        if (!w)
                return;
@@ -633,6 +635,7 @@ WIMLIBAPI void wimlib_free(WIMStruct *w)
        }
 #endif
        FREE(w);
+       DEBUG("Freed WIMStruct");
 }
 
 /* Get global memory allocations out of the way.  Not strictly necessary in