Corrected image path bug with -add of regular files, and -add /=/some/dir

This commit is contained in:
Thomas Schmitt 2007-10-15 20:37:53 +00:00
parent 7a768d6f5a
commit 54bf7b64c7
2 changed files with 43 additions and 7 deletions

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.15.203554"
#define Xorriso_timestamP "2007.10.15.203714"

View File

@ -314,9 +314,21 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
char path[SfileadrL], *apt, *npt;
struct iso_tree_node_dir *dir;
struct iso_tree_node *node;
int done= 0, is_dir= 0;
int done= 0, is_dir= 0, l;
struct stat stbuf;
if(xorriso->in_volset_handle==NULL) {
/* >>> */
fprintf(stderr, "--- No volset is loaded.\n");
if(xorriso->indev[0]==0)
fprintf(stderr, "--- No -dev or -indev is selected.\n");
else
fprintf(stderr, "--- Possible program error with drive '%s'\n",
xorriso->indev);
return(0);
}
strncpy(path, img_path, sizeof(path)-1);
path[sizeof(path)-1]= 0;
apt= npt= path;
@ -331,8 +343,8 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
return(0);
}
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) {
/* >>> */
@ -340,6 +352,19 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
disk_path);
return(0);
} else {
l= strlen(img_path);
if(l>0)
if(img_path[l-1]=='/')
l= 0;
if(l==0) {
/* >>> */
fprintf(stderr,
"--- Source '%s' is not a directory. Target '%s' would be.\n",
disk_path, img_path);
}
}
dir= iso_volume_get_root(volume);
@ -361,20 +386,29 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
if(*apt==0) {
*apt= '/';
apt++;
if(done)
goto attach_source;
continue;
}
node= iso_tree_volume_path_to_node(volume,path);
if(node!=NULL) {
if(iso_tree_node_get_type(node)!=LIBISO_NODE_DIR) {
if(done) {
/* >>> handle overwrite situation */;
}
/* >>> */
fprintf(stderr, "--- While grafting '%s' : '%s' is not a directory\n",
img_path, path);
fprintf(stderr,
"--- While grafting '%s' : '%s' exists and is not a directory\n",
img_path, path);
return(0);
}
dir= (struct iso_tree_node_dir *) node;
} else {
} else if(is_dir || !done) {
dir= iso_tree_add_dir(dir, apt);
if(dir==NULL) {
@ -386,6 +420,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
}
}
if(done) {
attach_source:;
if(is_dir) {
iso_tree_radd_dir(dir, disk_path, &behav);
} else {
@ -398,6 +433,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
return(0);
}
iso_tree_node_set_name(node, apt);
}
} else
*npt= '/';