X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwim.c;h=ec345a9322e0d51e5fb9af5e10eee1579e050033;hb=3a803d0087d51ea3caa80378bbae615fa45537c5;hp=79a9ba729e08d48b270b7dd538f946b092ee5cf5;hpb=81d03c562d98c865fb2c03978231c250f68cb0a7;p=wimlib diff --git a/src/wim.c b/src/wim.c index 79a9ba72..ec345a93 100644 --- a/src/wim.c +++ b/src/wim.c @@ -25,9 +25,6 @@ #include #include -#ifndef __WIN32__ -# include -#endif #include #include #include @@ -40,7 +37,6 @@ #include "wimlib/file_io.h" #include "wimlib/integrity.h" #include "wimlib/metadata.h" -#include "wimlib/ntfs_3g.h" /* for libntfs3g_global_init() */ #include "wimlib/security.h" #include "wimlib/wim.h" #include "wimlib/xml.h" @@ -162,7 +158,7 @@ wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret) int ret; WIMStruct *wim; - ret = wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = wimlib_global_init(0); if (ret) return ret; @@ -176,31 +172,25 @@ wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret) if (!wim) return WIMLIB_ERR_NOMEM; - wim->xml_info = xml_new_info_struct(); - wim->blob_table = new_blob_table(64); - if (!wim->xml_info || !wim->blob_table) { - wimlib_free(wim); - return WIMLIB_ERR_NOMEM; - } - - /* Fill in wim->hdr with default values */ + /* Fill in wim->hdr with default values */ wim->hdr.magic = WIM_MAGIC; wim->hdr.wim_version = WIM_VERSION_DEFAULT; - wim->hdr.flags = 0; - wim->hdr.chunk_size = 0; - generate_guid(wim->hdr.guid); wim->hdr.part_number = 1; wim->hdr.total_parts = 1; - wim->hdr.image_count = 0; - wim->hdr.boot_idx = 0; - wim->compression_type = WIMLIB_COMPRESSION_TYPE_NONE; - wim->chunk_size = wim->hdr.chunk_size; - /* Set the output compression type */ + /* Set the output compression type */ wim->out_compression_type = ctype; wim->out_chunk_size = wim_default_nonsolid_chunk_size(ctype); + /* Allocate an empty XML info and blob table */ + wim->xml_info = xml_new_info_struct(); + wim->blob_table = new_blob_table(64); + if (!wim->xml_info || !wim->blob_table) { + wimlib_free(wim); + return WIMLIB_ERR_NOMEM; + } + *wim_ret = wim; return 0; } @@ -790,7 +780,7 @@ open_wim_as_WIMStruct(const void *wim_filename_or_fd, int open_flags, WIMStruct *wim; int ret; - ret = wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = wimlib_global_init(0); if (ret) return ret; @@ -936,21 +926,6 @@ wimlib_free(WIMStruct *wim) wim_decrement_refcnt(wim); } -static bool -test_locale_ctype_utf8(void) -{ -#ifdef __WIN32__ - return false; -#else - char *ctype = nl_langinfo(CODESET); - - return (!strstr(ctype, "UTF-8") || - !strstr(ctype, "UTF8") || - !strstr(ctype, "utf8") || - !strstr(ctype, "utf-8")); -#endif -} - /* API function documented in wimlib.h */ WIMLIBAPI u32 wimlib_get_version(void) @@ -999,19 +974,11 @@ wimlib_global_init(int init_flags) goto out_unlock; xml_global_init(); - if (!(init_flags & WIMLIB_INIT_FLAG_ASSUME_UTF8)) { - wimlib_mbs_is_utf8 = test_locale_ctype_utf8(); - #ifdef WITH_NTFS_3G - if (!wimlib_mbs_is_utf8) - libntfs3g_global_init(); - #endif - } #ifdef __WIN32__ ret = win32_global_init(init_flags); if (ret) goto out_unlock; #endif - iconv_global_init(); init_upcase(); if (init_flags & WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE) default_ignore_case = false; @@ -1038,7 +1005,6 @@ wimlib_global_cleanup(void) goto out_unlock; xml_global_cleanup(); - iconv_global_cleanup(); #ifdef __WIN32__ win32_global_cleanup(); #endif