#include "lookup_table.h"
#include "xml.h"
-
static int print_metadata(WIMStruct *w)
{
DEBUG("Printing metadata for image %d", w->current_image);
int image;
int i;
- if (!image_name_or_num)
+ if (!image_name_or_num || !*image_name_or_num)
return WIMLIB_NO_IMAGE;
if (strcmp(image_name_or_num, "all") == 0
|| strcmp(image_name_or_num, "*") == 0)
return WIMLIB_ALL_IMAGES;
image = strtol(image_name_or_num, &p, 10);
- if (p != image_name_or_num && *p == '\0') {
- if (image < 1 || image > w->hdr.image_count)
+ if (p != image_name_or_num && *p == '\0' && image > 0) {
+ if (image > w->hdr.image_count)
return WIMLIB_NO_IMAGE;
return image;
} else {
}
/* Opens a WIM readable */
-int open_wim_readable(WIMStruct *w, const char *path)
+static int open_wim_readable(WIMStruct *w, const char *path)
{
if (w->fp != NULL)
fclose(w->fp);
return 0;
}
-/* Opens a WIM writable */
-int open_wim_writable(WIMStruct *w, const char *path,
- bool trunc, bool readable)
-{
- const char *mode;
- if (trunc)
- if (readable)
- mode = "w+b";
- else
- mode = "wb";
- else
- mode = "r+b";
-
- DEBUG("Opening `%s' read-write", path);
- wimlib_assert(w->out_fp == NULL);
- wimlib_assert(path != NULL);
- w->out_fp = fopen(path, mode);
- if (!w->out_fp) {
- ERROR_WITH_ERRNO("Failed to open `%s' for writing", path);
- return WIMLIB_ERR_OPEN;
- }
- return 0;
-}
-
/*
* Begins the reading of a WIM file; opens the file and reads its header and
* lookup table, and optionally checks the integrity.