Change recOpts in Image, it can be part of the Image struct, not a ptr.

This commit is contained in:
Vreixo Formoso 2007-12-29 16:49:04 +01:00
parent 71cd3ccb89
commit 501275279d
4 changed files with 50 additions and 59 deletions

View File

@ -99,7 +99,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
name = iso_file_source_get_name(src); name = iso_file_source_get_name(src);
/* get info about source */ /* get info about source */
if (image->recOpts->follow_symlinks) { if (image->recOpts.follow_symlinks) {
result = iso_file_source_stat(src, &info); result = iso_file_source_stat(src, &info);
} else { } else {
result = iso_file_source_lstat(src, &info); result = iso_file_source_lstat(src, &info);

View File

@ -77,15 +77,6 @@ int iso_image_new(const char *name, IsoImage **image)
return res; return res;
} }
img->refcount = 1; 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) { if (name != NULL) {
img->volset_id = strdup(name); img->volset_id = strdup(name);
@ -116,7 +107,6 @@ void iso_image_unref(IsoImage *image)
libiso_msgs_destroy(&image->messenger, 0); libiso_msgs_destroy(&image->messenger, 0);
iso_node_builder_unref(image->builder); iso_node_builder_unref(image->builder);
iso_filesystem_unref(image->fs); iso_filesystem_unref(image->fs);
free(image->recOpts);
free(image->volset_id); free(image->volset_id);
free(image->volume_id); free(image->volume_id);
free(image->publisher_id); free(image->publisher_id);

View File

@ -24,43 +24,6 @@
typedef struct Iso_Image_Rec_Opts IsoImageRecOpts; 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 * Options for recursive directory addition
*/ */
@ -119,4 +82,41 @@ struct Iso_Image_Rec_Opts
int (*report)(IsoFileSource *src, int action, int flag); 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_*/ #endif /*LIBISO_IMAGE_H_*/

View File

@ -369,10 +369,10 @@ static
int check_excludes(IsoImage *image, const char *path) int check_excludes(IsoImage *image, const char *path)
{ {
char **exclude; char **exclude;
if (image->recOpts->excludes == NULL) { if (image->recOpts.excludes == NULL) {
return 0; return 0;
} }
exclude = image->recOpts->excludes; exclude = image->recOpts.excludes;
while (*exclude) { while (*exclude) {
if (strcmp(*exclude, path) == 0) { if (strcmp(*exclude, path) == 0) {
return 1; return 1;
@ -385,7 +385,7 @@ int check_excludes(IsoImage *image, const char *path)
static static
int check_hidden(IsoImage *image, const char *name) 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)) { if (*pos != NULL && !strcmp((*pos)->name, name)) {
flag = 1; flag = 1;
if (action == 1 && image->recOpts->replace == 0) { if (action == 1 && image->recOpts.replace == 0) {
action = 2; action = 2;
} }
} }
@ -444,8 +444,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
free(name); free(name);
/* ask user if callback has been set */ /* ask user if callback has been set */
if (image->recOpts->report) { if (image->recOpts.report) {
action = image->recOpts->report(file, action, flag); action = image->recOpts.report(file, action, flag);
} }
if (action == 2) { 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 " iso_msg_note(image, LIBISO_FILE_IGNORED, "Error %d when adding "
"file %s", result, iso_file_source_get_path(file)); "file %s", result, iso_file_source_get_path(file));
if (image->recOpts->report) { if (image->recOpts.report) {
action = image->recOpts->report(file, result, flag); action = image->recOpts.report(file, result, flag);
} else { } else {
action = image->recOpts->stop_on_error ? 3 : 1; action = image->recOpts.stop_on_error ? 3 : 1;
} }
/* free file */ /* free file */
@ -506,7 +506,7 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
iso_file_source_unref(file); iso_file_source_unref(file);
if (result < 0) { if (result < 0) {
/* error */ /* error */
if (image->recOpts->stop_on_error) { if (image->recOpts.stop_on_error) {
action = 3; /* stop */ action = 3; /* stop */
result = 1; /* prevent error to be passing up */ result = 1; /* prevent error to be passing up */
break; break;
@ -522,7 +522,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
} }
if (result < 0) { 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; action = result;
} }