From: Eric Biggers Date: Tue, 5 Mar 2013 21:14:22 +0000 (-0600) Subject: Move default capture config policy to library users X-Git-Tag: v1.2.6~6 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=1d8b904a7424f6e38bcba0b2c3a3078f43781029;ds=sidebyside Move default capture config policy to library users --- diff --git a/programs/imagex.c b/programs/imagex.c index e7ebc2eb..eb2e442f 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -280,6 +280,21 @@ static off_t file_get_size(const char *filename) return (off_t)-1; } +static const char *default_capture_config = +"[ExclusionList]\n" +"\\$ntfs.log\n" +"\\hiberfil.sys\n" +"\\pagefile.sys\n" +"\\System Volume Information\n" +"\\RECYCLER\n" +"\\Windows\\CSC\n" +"\n" +"[CompressionExclusionList]\n" +"*.mp3\n" +"*.zip\n" +"*.cab\n" +"\\WINDOWS\\inf\\*.pnf\n"; + static char *file_get_contents(const char *filename, size_t *len_ret) { struct stat stbuf; @@ -769,8 +784,10 @@ static int imagex_capture_or_append(int argc, const char **argv) } } - ret = wimlib_add_image(w, source, name, config_str, config_len, - add_image_flags, imagex_progress_func); + ret = wimlib_add_image(w, source, name, + config_str ? config_str : default_capture_config, + config_len, add_image_flags, + imagex_progress_func); if (ret != 0) goto out; diff --git a/src/add_image.c b/src/add_image.c index 3e604e3a..61ed0132 100644 --- a/src/add_image.c +++ b/src/add_image.c @@ -396,8 +396,13 @@ enum pattern_type { ALIGNMENT_LIST, }; +#define COMPAT_DEFAULT_CONFIG + /* Default capture configuration file when none is specified. */ static const char *default_config = +#ifdef COMPAT_DEFAULT_CONFIG /* XXX: This policy is being moved to library + users. The next ABI-incompatible library + version will default to the empty string here. */ "[ExclusionList]\n" "\\$ntfs.log\n" "\\hiberfil.sys\n" @@ -411,6 +416,9 @@ static const char *default_config = "*.zip\n" "*.cab\n" "\\WINDOWS\\inf\\*.pnf\n"; +#else +""; +#endif static void destroy_pattern_list(struct pattern_list *list) { @@ -583,21 +591,6 @@ static bool match_pattern(const char *path, const char *path_basename, return false; } -static void print_pattern_list(const struct pattern_list *list) -{ - for (size_t i = 0; i < list->num_pats; i++) - printf(" %s\n", list->pats[i]); -} - -static void print_capture_config(const struct capture_config *config) -{ - if (config->exclusion_list.num_pats) { - puts("Files or folders excluded from image capture:"); - print_pattern_list(&config->exclusion_list); - putchar('\n'); - } -} - /* Return true if the image capture configuration file indicates we should * exclude the filename @path from capture. * @@ -694,7 +687,6 @@ WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *source, ret = init_capture_config(config_str, config_len, source, &config); if (ret != 0) return ret; - print_capture_config(&config); DEBUG("Allocating security data"); diff --git a/src/wimlib.h b/src/wimlib.h index d1ee1221..62a028de 100644 --- a/src/wimlib.h +++ b/src/wimlib.h @@ -809,8 +809,8 @@ enum wimlib_error_code { * NULL, a default string is used. Please see the manual page for * imagex capture for more information. * @param config_len - * Length of the string @a config in bytes. Ignored if @a config is @c - * NULL. + * Length of the string @a config in bytes, not including an optional + * null-terminator. Ignored if @a config is @c NULL. * @param add_image_flags * Bitwise OR of flags prefixed with WIMLIB_ADD_IMAGE_FLAG. * @param progress_func