Change recOpts in Image, it can be part of the Image struct, not a ptr.
This commit is contained in:
parent
71cd3ccb89
commit
501275279d
@ -99,7 +99,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
name = iso_file_source_get_name(src);
|
||||
|
||||
/* get info about source */
|
||||
if (image->recOpts->follow_symlinks) {
|
||||
if (image->recOpts.follow_symlinks) {
|
||||
result = iso_file_source_stat(src, &info);
|
||||
} else {
|
||||
result = iso_file_source_lstat(src, &info);
|
||||
|
10
src/image.c
10
src/image.c
@ -77,15 +77,6 @@ int iso_image_new(const char *name, IsoImage **image)
|
||||
return res;
|
||||
}
|
||||
img->refcount = 1;
|
||||
img->recOpts = calloc(1, sizeof(IsoImageRecOpts));
|
||||
if (img->recOpts == NULL) {
|
||||
libiso_msgs_destroy(&img->messenger, 0);
|
||||
iso_node_builder_unref(img->builder);
|
||||
iso_filesystem_unref(img->fs);
|
||||
iso_node_unref((IsoNode*)img->root);
|
||||
free(img);
|
||||
return ISO_MEM_ERROR;
|
||||
}
|
||||
|
||||
if (name != NULL) {
|
||||
img->volset_id = strdup(name);
|
||||
@ -116,7 +107,6 @@ void iso_image_unref(IsoImage *image)
|
||||
libiso_msgs_destroy(&image->messenger, 0);
|
||||
iso_node_builder_unref(image->builder);
|
||||
iso_filesystem_unref(image->fs);
|
||||
free(image->recOpts);
|
||||
free(image->volset_id);
|
||||
free(image->volume_id);
|
||||
free(image->publisher_id);
|
||||
|
74
src/image.h
74
src/image.h
@ -24,43 +24,6 @@
|
||||
|
||||
typedef struct Iso_Image_Rec_Opts IsoImageRecOpts;
|
||||
|
||||
struct Iso_Image
|
||||
{
|
||||
|
||||
int refcount;
|
||||
|
||||
IsoDir *root;
|
||||
|
||||
char *volset_id;
|
||||
|
||||
char *volume_id; /**< Volume identifier. */
|
||||
char *publisher_id; /**< Volume publisher. */
|
||||
char *data_preparer_id; /**< Volume data preparer. */
|
||||
char *system_id; /**< Volume system identifier. */
|
||||
char *application_id; /**< Volume application id */
|
||||
char *copyright_file_id;
|
||||
char *abstract_file_id;
|
||||
char *biblio_file_id;
|
||||
|
||||
/* message messenger for the image */
|
||||
struct libiso_msgs *messenger;
|
||||
|
||||
/**
|
||||
* Default filesystem to use when adding files to the image tree.
|
||||
*/
|
||||
IsoFilesystem *fs;
|
||||
|
||||
/*
|
||||
* Default builder to use when adding files to the image tree.
|
||||
*/
|
||||
IsoNodeBuilder *builder;
|
||||
|
||||
/**
|
||||
* Options for recursive directory addition
|
||||
*/
|
||||
IsoImageRecOpts *recOpts;
|
||||
};
|
||||
|
||||
/**
|
||||
* Options for recursive directory addition
|
||||
*/
|
||||
@ -119,4 +82,41 @@ struct Iso_Image_Rec_Opts
|
||||
int (*report)(IsoFileSource *src, int action, int flag);
|
||||
};
|
||||
|
||||
struct Iso_Image
|
||||
{
|
||||
|
||||
int refcount;
|
||||
|
||||
IsoDir *root;
|
||||
|
||||
char *volset_id;
|
||||
|
||||
char *volume_id; /**< Volume identifier. */
|
||||
char *publisher_id; /**< Volume publisher. */
|
||||
char *data_preparer_id; /**< Volume data preparer. */
|
||||
char *system_id; /**< Volume system identifier. */
|
||||
char *application_id; /**< Volume application id */
|
||||
char *copyright_file_id;
|
||||
char *abstract_file_id;
|
||||
char *biblio_file_id;
|
||||
|
||||
/* message messenger for the image */
|
||||
struct libiso_msgs *messenger;
|
||||
|
||||
/**
|
||||
* Default filesystem to use when adding files to the image tree.
|
||||
*/
|
||||
IsoFilesystem *fs;
|
||||
|
||||
/*
|
||||
* Default builder to use when adding files to the image tree.
|
||||
*/
|
||||
IsoNodeBuilder *builder;
|
||||
|
||||
/**
|
||||
* Options for recursive directory addition
|
||||
*/
|
||||
IsoImageRecOpts recOpts;
|
||||
};
|
||||
|
||||
#endif /*LIBISO_IMAGE_H_*/
|
||||
|
23
src/tree.c
23
src/tree.c
@ -369,10 +369,10 @@ static
|
||||
int check_excludes(IsoImage *image, const char *path)
|
||||
{
|
||||
char **exclude;
|
||||
if (image->recOpts->excludes == NULL) {
|
||||
if (image->recOpts.excludes == NULL) {
|
||||
return 0;
|
||||
}
|
||||
exclude = image->recOpts->excludes;
|
||||
exclude = image->recOpts.excludes;
|
||||
while (*exclude) {
|
||||
if (strcmp(*exclude, path) == 0) {
|
||||
return 1;
|
||||
@ -385,7 +385,7 @@ int check_excludes(IsoImage *image, const char *path)
|
||||
static
|
||||
int check_hidden(IsoImage *image, const char *name)
|
||||
{
|
||||
return (image->recOpts->ignore_hidden && name[0] == '.');
|
||||
return (image->recOpts.ignore_hidden && name[0] == '.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,7 +435,7 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
}
|
||||
if (*pos != NULL && !strcmp((*pos)->name, name)) {
|
||||
flag = 1;
|
||||
if (action == 1 && image->recOpts->replace == 0) {
|
||||
if (action == 1 && image->recOpts.replace == 0) {
|
||||
action = 2;
|
||||
}
|
||||
}
|
||||
@ -444,8 +444,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
free(name);
|
||||
|
||||
/* ask user if callback has been set */
|
||||
if (image->recOpts->report) {
|
||||
action = image->recOpts->report(file, action, flag);
|
||||
if (image->recOpts.report) {
|
||||
action = image->recOpts.report(file, action, flag);
|
||||
}
|
||||
|
||||
if (action == 2) {
|
||||
@ -465,10 +465,10 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
iso_msg_note(image, LIBISO_FILE_IGNORED, "Error %d when adding "
|
||||
"file %s", result, iso_file_source_get_path(file));
|
||||
|
||||
if (image->recOpts->report) {
|
||||
action = image->recOpts->report(file, result, flag);
|
||||
if (image->recOpts.report) {
|
||||
action = image->recOpts.report(file, result, flag);
|
||||
} else {
|
||||
action = image->recOpts->stop_on_error ? 3 : 1;
|
||||
action = image->recOpts.stop_on_error ? 3 : 1;
|
||||
}
|
||||
|
||||
/* free file */
|
||||
@ -506,7 +506,7 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
iso_file_source_unref(file);
|
||||
if (result < 0) {
|
||||
/* error */
|
||||
if (image->recOpts->stop_on_error) {
|
||||
if (image->recOpts.stop_on_error) {
|
||||
action = 3; /* stop */
|
||||
result = 1; /* prevent error to be passing up */
|
||||
break;
|
||||
@ -522,7 +522,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
// TODO printf message
|
||||
/* error reading dir, should never occur */
|
||||
iso_msg_sorry(image, LIBISO_CANT_READ_FILE, "Error reading dir");
|
||||
action = result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user