X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwim.c;h=73f0060e834dc5302574baa98b60ece2dc871986;hb=87345050a103f26b8bd4be4b26f26e2931345317;hp=2a3c08c10eda14a8e58453736a8095f455620336;hpb=bcec8f6839a4e72db751bb8fd5d7559e1cd7ea7f;p=wimlib diff --git a/src/wim.c b/src/wim.c index 2a3c08c1..73f0060e 100644 --- a/src/wim.c +++ b/src/wim.c @@ -125,6 +125,8 @@ wimlib_create_new_wim(int ctype, WIMStruct **w_ret) struct wim_lookup_table *table; int ret; + wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + DEBUG("Creating new WIM with %"TS" compression.", wimlib_get_compression_type_string(ctype)); @@ -174,6 +176,11 @@ select_wim_image(WIMStruct *w, int image) return WIMLIB_ERR_INVALID_IMAGE; } + if (w->hdr.part_number != 1) { + ERROR("Cannot select an image from a non-first part of a split WIM"); + return WIMLIB_ERR_SPLIT_UNSUPPORTED; + } + /* If a valid image is currently selected, it can be freed if it is not * modified. */ if (w->current_image != WIMLIB_NO_IMAGE) { @@ -252,37 +259,31 @@ wimlib_resolve_image(WIMStruct *w, const tchar *image_name_or_num) /* Prints some basic information about a WIM file. */ WIMLIBAPI void -wimlib_print_wim_information(const WIMStruct *w) +wimlib_print_wim_information(const WIMStruct *wim) { - const struct wim_header *hdr; + struct wimlib_wim_info info; + + wimlib_get_wim_info((WIMStruct*)wim, &info); - hdr = &w->hdr; tputs(T("WIM Information:")); tputs(T("----------------")); - tprintf(T("Path: %"TS"\n"), w->filename); + tprintf(T("Path: %"TS"\n"), wim->filename); tfputs(T("GUID: 0x"), stdout); - print_byte_field(hdr->guid, WIM_GID_LEN, stdout); + print_byte_field(info.guid, WIM_GID_LEN, stdout); tputchar(T('\n')); - tprintf(T("Image Count: %d\n"), hdr->image_count); + tprintf(T("Image Count: %d\n"), info.image_count); tprintf(T("Compression: %"TS"\n"), - wimlib_get_compression_type_string(w->compression_type)); - tprintf(T("Part Number: %d/%d\n"), hdr->part_number, hdr->total_parts); - tprintf(T("Boot Index: %d\n"), hdr->boot_idx); - tprintf(T("Size: %"PRIu64" bytes\n"), - wim_info_get_total_bytes(w->wim_info)); + wimlib_get_compression_type_string(info.compression_type)); + tprintf(T("Part Number: %d/%d\n"), info.part_number, info.total_parts); + tprintf(T("Boot Index: %d\n"), info.boot_index); + tprintf(T("Size: %"PRIu64" bytes\n"), info.total_bytes); tprintf(T("Integrity Info: %"TS"\n"), - (w->hdr.integrity.offset != 0) ? T("yes") : T("no")); + info.has_integrity_table ? T("yes") : T("no")); tprintf(T("Relative path junction: %"TS"\n"), - (hdr->flags & WIM_HDR_FLAG_RP_FIX) ? T("yes") : T("no")); + info.has_rpfix ? T("yes") : T("no")); tputchar(T('\n')); } -WIMLIBAPI bool -wimlib_has_integrity_table(const WIMStruct *w) -{ - return w->hdr.integrity.size != 0; -} - WIMLIBAPI void wimlib_print_available_images(const WIMStruct *w, int image) { @@ -355,7 +356,7 @@ wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info) info->total_bytes = 0; info->has_integrity_table = wim->hdr.integrity.offset != 0; info->opened_from_file = (wim->filename != NULL); - info->is_readonly == (wim->hdr.flags & WIM_HDR_FLAG_READONLY) || + info->is_readonly = (wim->hdr.flags & WIM_HDR_FLAG_READONLY) || (wim->hdr.total_parts != 1) || (wim->filename && taccess(wim->filename, W_OK)); info->has_rpfix = (wim->hdr.flags & WIM_HDR_FLAG_RP_FIX) != 0; @@ -410,6 +411,16 @@ wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret) return info.part_number; } +/* Deprecated */ +WIMLIBAPI bool +wimlib_has_integrity_table(const WIMStruct *wim) +{ + struct wimlib_wim_info info; + + wimlib_get_wim_info((WIMStruct*)wim, &info); + return info.has_integrity_table; +} + WIMLIBAPI int wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info, int which) { @@ -634,6 +645,8 @@ wimlib_open_wim(const tchar *wim_file, int open_flags, WIMStruct *wim; int ret; + wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = WIMLIB_ERR_INVALID_PARAM; if (!wim_file || !wim_ret) goto out; @@ -880,6 +893,10 @@ test_locale_ctype_utf8(void) WIMLIBAPI int wimlib_global_init(int init_flags) { + static bool already_inited = false; + + if (already_inited) + return 0; libxml_global_init(); if (!(init_flags & WIMLIB_INIT_FLAG_ASSUME_UTF8)) { wimlib_mbs_is_utf8 = test_locale_ctype_utf8(); @@ -891,6 +908,7 @@ wimlib_global_init(int init_flags) #ifdef __WIN32__ win32_global_init(); #endif + already_inited = true; return 0; }