X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fcapture_common.c;h=e544b7c126794f0e5013b684d9c3d83f455058de;hb=80b48ed7aeb8e6c9460ab254920818f9e36d656e;hp=caf9529c3b70b5b85f7313ab867241010f289984;hpb=f7c0992ff2b5c7f9c178262d5ede6910b039eba8;p=wimlib diff --git a/src/capture_common.c b/src/capture_common.c index caf9529c..e544b7c1 100644 --- a/src/capture_common.c +++ b/src/capture_common.c @@ -5,37 +5,35 @@ /* * Copyright (C) 2013, 2014 Eric Biggers * - * This file is part of wimlib, a library for working with WIM files. + * 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 + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. * - * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * - * You should have received a copy of the GNU General Public License - * along with wimlib; if not, see http://www.gnu.org/licenses/. + * 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/. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include + +#include "wimlib/blob_table.h" #include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/error.h" -#include "wimlib/lookup_table.h" #include "wimlib/paths.h" #include "wimlib/progress.h" #include "wimlib/textfile.h" #include "wimlib/wildcard.h" -#include - /* * Tally a file (or directory) that has been scanned for a capture operation, * and possibly call the progress function provided by the library user. @@ -52,7 +50,7 @@ * via additional hard links, inode->i_nlink will be greater than 1. */ int -do_capture_progress(struct add_image_params *params, int status, +do_capture_progress(struct capture_params *params, int status, const struct wim_inode *inode) { switch (status) { @@ -73,12 +71,12 @@ do_capture_progress(struct add_image_params *params, int status, /* Successful scan, and visiting inode for the first time */ - /* Tally size of all data streams. */ - const struct wim_lookup_table_entry *lte; - for (unsigned i = 0; i <= inode->i_num_ads; i++) { - lte = inode_stream_lte_resolved(inode, i); - if (lte) - params->progress.scan.num_bytes_scanned += lte->size; + /* Tally size of all streams. */ + for (unsigned i = 0; i < inode->i_num_streams; i++) { + const struct blob_descriptor *blob = + stream_blob_resolved(&inode->i_streams[i]); + if (blob) + params->progress.scan.num_bytes_scanned += blob->size; } /* Tally the file itself. */ @@ -205,8 +203,25 @@ read_capture_config(const tchar *config_file, const void *buf, ret = do_load_text_file(config_file, buf, bufsize, &mem, sections, ARRAY_LEN(sections), LOAD_TEXT_FILE_REMOVE_QUOTES, mangle_pat); - if (ret) + if (ret) { + ERROR("Failed to load capture configuration file \"%"TS"\"", + config_file); + switch (ret) { + case WIMLIB_ERR_INVALID_UTF8_STRING: + case WIMLIB_ERR_INVALID_UTF16_STRING: + ERROR("Note: the capture configuration file must be " + "valid UTF-8 or UTF-16LE"); + ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG; + break; + case WIMLIB_ERR_OPEN: + case WIMLIB_ERR_STAT: + case WIMLIB_ERR_NOMEM: + case WIMLIB_ERR_READ: + ret = WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG; + break; + } return ret; + } FREE(prepopulate_pats.strings); FREE(compression_exclusion_pats.strings); @@ -300,7 +315,7 @@ should_exclude_path(const tchar *path, size_t path_nchars, */ int try_exclude(const tchar *full_path, size_t full_path_nchars, - const struct add_image_params *params) + const struct capture_params *params) { int ret;