Move recOpts to IsoImage and remove that unneeded struct.

This commit is contained in:
Vreixo Formoso 2008-01-23 21:38:09 +01:00
parent 2515c28de9
commit 8b7d9eddb6
2 changed files with 51 additions and 65 deletions

View File

@ -22,13 +22,39 @@
* [The stuff we have in init belongs really to image!]
*/
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;
/* el-torito boot catalog */
struct el_torito_boot_catalog *bootcat;
/* image identifier, for message origin identifier */
int id;
/**
* Options for recursive directory addition
* Default filesystem to use when adding files to the image tree.
*/
struct Iso_Image_Rec_Opts
{
IsoFilesystem *fs;
/*
* Default builder to use when adding files to the image tree.
*/
IsoNodeBuilder *builder;
/**
* Whether to follow symlinks or just add them as symlinks
@ -77,44 +103,4 @@ struct Iso_Image_Rec_Opts
int (*report)(IsoFileSource *src);
};
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;
/* el-torito boot catalog */
struct el_torito_boot_catalog *bootcat;
/* image identifier, for message origin identifier */
int id;
/**
* 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_*/

View File

@ -303,7 +303,7 @@ int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
*/
void iso_tree_set_follow_symlinks(IsoImage *image, int follow)
{
image->recOpts.follow_symlinks = follow ? 1 : 0;
image->follow_symlinks = follow ? 1 : 0;
}
/**
@ -313,7 +313,7 @@ void iso_tree_set_follow_symlinks(IsoImage *image, int follow)
*/
int iso_tree_get_follow_symlinks(IsoImage *image)
{
return image->recOpts.follow_symlinks;
return image->follow_symlinks;
}
/**
@ -322,7 +322,7 @@ int iso_tree_get_follow_symlinks(IsoImage *image)
*/
void iso_tree_set_ignore_hidden(IsoImage *image, int skip)
{
image->recOpts.ignore_hidden = skip ? 1 : 0;
image->ignore_hidden = skip ? 1 : 0;
}
/**
@ -332,7 +332,7 @@ void iso_tree_set_ignore_hidden(IsoImage *image, int skip)
*/
int iso_tree_get_ignore_hidden(IsoImage *image)
{
return image->recOpts.ignore_hidden;
return image->ignore_hidden;
}
/**
@ -349,7 +349,7 @@ int iso_tree_get_ignore_hidden(IsoImage *image)
*/
void iso_tree_set_ignore_special(IsoImage *image, int skip)
{
image->recOpts.ignore_special = skip & 0x0F;
image->ignore_special = skip & 0x0F;
}
/**
@ -359,7 +359,7 @@ void iso_tree_set_ignore_special(IsoImage *image, int skip)
*/
int iso_tree_get_ignore_special(IsoImage *image)
{
return image->recOpts.ignore_special;
return image->ignore_special;
}
/**
@ -378,7 +378,7 @@ int iso_tree_get_ignore_special(IsoImage *image)
void iso_tree_set_report_callback(IsoImage *image,
int (*report)(IsoFileSource *src))
{
image->recOpts.report = report;
image->report = report;
}
static
@ -448,10 +448,10 @@ static
int check_excludes(IsoImage *image, const char *path)
{
char **exclude;
if (image->recOpts.excludes == NULL) {
if (image->excludes == NULL) {
return 0;
}
exclude = image->recOpts.excludes;
exclude = image->excludes;
while (*exclude) {
if (strcmp(*exclude, path) == 0) {
return 1;
@ -464,22 +464,22 @@ 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->ignore_hidden && name[0] == '.');
}
static
int check_special(IsoImage *image, mode_t mode)
{
if (image->recOpts.ignore_special != 0) {
if (image->ignore_special != 0) {
switch(mode & S_IFMT) {
case S_IFBLK:
return image->recOpts.ignore_special & 0x08 ? 1 : 0;
return image->ignore_special & 0x08 ? 1 : 0;
case S_IFCHR:
return image->recOpts.ignore_special & 0x04 ? 1 : 0;
return image->ignore_special & 0x04 ? 1 : 0;
case S_IFSOCK:
return image->recOpts.ignore_special & 0x02 ? 1 : 0;
return image->ignore_special & 0x02 ? 1 : 0;
case S_IFIFO:
return image->recOpts.ignore_special & 0x01 ? 1 : 0;
return image->ignore_special & 0x01 ? 1 : 0;
default:
return 0;
}
@ -532,7 +532,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
path = iso_file_source_get_path(file);
name = strrchr(path, '/') + 1;
if (image->recOpts.follow_symlinks) {
if (image->follow_symlinks) {
ret = iso_file_source_stat(file, &info);
} else {
ret = iso_file_source_lstat(file, &info);
@ -556,7 +556,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
goto dir_rec_continue;
}
replace = image->recOpts.replace;
replace = image->replace;
/* find place where to insert */
ret = iso_dir_exists(parent, name, &pos);
@ -574,8 +574,8 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
}
/* if we are here we must insert. Give user a chance for cancel */
if (image->recOpts.report) {
int r = image->recOpts.report(file);
if (image->report) {
int r = image->report(file);
if (r <= 0) {
ret = (r < 0 ? ISO_CANCELED : ISO_SUCCESS);
goto dir_rec_continue;