X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwim.c;h=ca40e53a47a303b4dbe3cb44e2172e2976e91da5;hp=e9a6c8eba1ca665d619272e82c9eb92c1ed2faf8;hb=HEAD;hpb=14a395345aaa9dce84bf178a86243388c1c9f497 diff --git a/src/wim.c b/src/wim.c index e9a6c8eb..3a2a216a 100644 --- a/src/wim.c +++ b/src/wim.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2012-2016 Eric Biggers + * Copyright 2012-2023 Eric Biggers * * This file is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -16,7 +16,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public License - * along with this file; if not, see http://www.gnu.org/licenses/. + * along with this file; if not, see https://www.gnu.org/licenses/. */ #ifdef HAVE_CONFIG_H @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "wimlib.h" @@ -644,11 +645,17 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, int open_flags) filedes_init(&wim->in_fd, *(const int*)wim_filename_or_fd); wim->in_fd.is_pipe = 1; } else { + struct stat stbuf; + wimfile = wim_filename_or_fd; ret = open_wim_file(wimfile, &wim->in_fd); if (ret) return ret; + /* The file size is needed for enforcing some limits later. */ + if (fstat(wim->in_fd.fd, &stbuf) == 0) + wim->file_size = stbuf.st_size; + /* The absolute path to the WIM is requested so that * wimlib_overwrite() still works even if the process changes * its working directory. This actually happens if a WIM is @@ -979,7 +986,6 @@ wimlib_global_init(int init_flags) goto out_unlock; init_cpu_features(); - xml_global_init(); #ifdef _WIN32 ret = win32_global_init(init_flags); if (ret) @@ -1010,7 +1016,6 @@ wimlib_global_cleanup(void) if (!lib_initialized) goto out_unlock; - xml_global_cleanup(); #ifdef _WIN32 win32_global_cleanup(); #endif