X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwim.c;h=44653f191f685e95de5e4b5fc9a0b022d5fd458c;hp=9dd9718d9500e03f574e175d33dd1b488ae12184;hb=7c83ef53090441de11cc78d8d26dc337cd7ac475;hpb=9b9a502863318d6208da2818b1d522346e5eee9e diff --git a/src/wim.c b/src/wim.c index 9dd9718d..44653f19 100644 --- a/src/wim.c +++ b/src/wim.c @@ -43,7 +43,6 @@ #include "lookup_table.h" #include "xml.h" - static int print_metadata(WIMStruct *w) { DEBUG("Printing metadata for image %d", w->current_image); @@ -276,15 +275,15 @@ WIMLIBAPI int wimlib_resolve_image(WIMStruct *w, const char *image_name_or_num) 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 { @@ -421,7 +420,7 @@ WIMLIBAPI int wimlib_get_boot_idx(const WIMStruct *w) } /* 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); @@ -435,30 +434,6 @@ int open_wim_readable(WIMStruct *w, const char *path) 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.