Add image contents recursively and volume attributes.
This commit is contained in:
parent
193fbaef8b
commit
22c73dc343
@ -15,6 +15,7 @@ src_libisofs_la_SOURCES = \
|
|||||||
src/error.h \
|
src/error.h \
|
||||||
src/node.h \
|
src/node.h \
|
||||||
src/node.c \
|
src/node.c \
|
||||||
|
src/tree.h \
|
||||||
src/tree.c \
|
src/tree.c \
|
||||||
src/image.h \
|
src/image.h \
|
||||||
src/image.c \
|
src/image.c \
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
#include "rockridge.h"
|
#include "rockridge.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "tree.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -1801,19 +1802,43 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* recursively add image */
|
/* recursively add image */
|
||||||
|
ret = iso_add_dir_src_rec(image, image->root, newroot);
|
||||||
|
|
||||||
|
iso_node_builder_unref(image->builder);
|
||||||
|
|
||||||
/* recover backed fs and builder */
|
/* error during recursive image addition? */
|
||||||
|
if (ret <= 0) {
|
||||||
|
goto import_revert;
|
||||||
/* set volume attributes */
|
|
||||||
|
|
||||||
|
|
||||||
if (features != NULL) {
|
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
/* free old root */
|
||||||
|
iso_node_unref((IsoNode*)oldroot);
|
||||||
|
|
||||||
|
/* recover backed fs and builder */
|
||||||
|
image->fs = fsback;
|
||||||
|
image->builder = blback;
|
||||||
|
|
||||||
|
{
|
||||||
|
_ImageFsData *data;
|
||||||
|
data = fs->fs.data;
|
||||||
|
|
||||||
|
/* set volume attributes */
|
||||||
|
iso_image_set_volset_id(image, data->volset_id);
|
||||||
|
iso_image_set_volume_id(image, data->volume_id);
|
||||||
|
iso_image_set_publisher_id(image, data->publisher_id);
|
||||||
|
iso_image_set_data_preparer_id(image, data->data_preparer_id);
|
||||||
|
iso_image_set_system_id(image, data->system_id);
|
||||||
|
iso_image_set_application_id(image, data->application_id);
|
||||||
|
iso_image_set_copyright_file_id(image, data->copyright_file_id);
|
||||||
|
iso_image_set_abstract_file_id(image, data->abstract_file_id);
|
||||||
|
iso_image_set_biblio_file_id(image, data->biblio_file_id);
|
||||||
|
|
||||||
|
if (features != NULL) {
|
||||||
|
features->hasJoliet = data->joliet;
|
||||||
|
features->hasRR = data->rr_version != 0;
|
||||||
|
features->size = data->nblocks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = ISO_SUCCESS;
|
ret = ISO_SUCCESS;
|
||||||
goto import_cleanup;
|
goto import_cleanup;
|
||||||
|
10
src/tree.c
10
src/tree.c
@ -17,6 +17,7 @@
|
|||||||
#include "fsource.h"
|
#include "fsource.h"
|
||||||
#include "builder.h"
|
#include "builder.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
#include "tree.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -446,11 +447,12 @@ int check_hidden(IsoImage *image, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Recursively add a given directory to the image tree.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* 1 continue, 0 stop, < 0 error
|
* 1 continue, 0 stop, < 0 error
|
||||||
*/
|
*/
|
||||||
static
|
int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||||
int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int action; /* 1 add, 2 skip, 3 stop, < 0 error */
|
int action; /* 1 add, 2 skip, 3 stop, < 0 error */
|
||||||
@ -564,7 +566,7 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
|||||||
|
|
||||||
/* finally, if the node is a directory we need to recurse */
|
/* finally, if the node is a directory we need to recurse */
|
||||||
if (new->type == LIBISO_DIR) {
|
if (new->type == LIBISO_DIR) {
|
||||||
result = iso_add_dir_aux(image, (IsoDir*)new, file);
|
result = iso_add_dir_src_rec(image, (IsoDir*)new, file);
|
||||||
iso_file_source_unref(file);
|
iso_file_source_unref(file);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
@ -631,7 +633,7 @@ int iso_tree_add_dir_rec(IsoImage *image, IsoDir *parent, const char *dir)
|
|||||||
iso_file_source_unref(file);
|
iso_file_source_unref(file);
|
||||||
return ISO_FILE_IS_NOT_DIR;
|
return ISO_FILE_IS_NOT_DIR;
|
||||||
}
|
}
|
||||||
result = iso_add_dir_aux(image, parent, file);
|
result = iso_add_dir_src_rec(image, parent, file);
|
||||||
iso_file_source_unref(file);
|
iso_file_source_unref(file);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
21
src/tree.h
Normal file
21
src/tree.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Vreixo Formoso
|
||||||
|
*
|
||||||
|
* This file is part of the libisofs project; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation. See COPYING file for details.
|
||||||
|
*/
|
||||||
|
#ifndef LIBISO_IMAGE_TREE_H_
|
||||||
|
#define LIBISO_IMAGE_TREE_H_
|
||||||
|
|
||||||
|
#include "image.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively add a given directory to the image tree.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* 1 continue, 0 stop, < 0 error
|
||||||
|
*/
|
||||||
|
int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir);
|
||||||
|
|
||||||
|
#endif /*LIBISO_IMAGE_TREE_H_*/
|
Loading…
Reference in New Issue
Block a user