New -find test -disk_path

This commit is contained in:
2012-06-21 20:34:40 +00:00
parent b796a99a03
commit 2edce33c2e
9 changed files with 179 additions and 59 deletions

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2011 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2012 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -2069,12 +2069,78 @@ int Xorriso__file_start_lba(IsoNode *node,
}
/* flag bit0= examine sub directories rather than data files
*/
int Xorriso_dir_disk_path(struct XorrisO *xorriso, IsoNode *dir_node,
char disk_path[SfileadrL], int flag)
{
int ret;
char *npt;
IsoNode *node;
IsoDir *dir;
IsoDirIter *iter= NULL;
dir= (IsoDir *) dir_node;
ret= iso_dir_get_children(dir, &iter);
if(ret<0) {
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
while(1) {
ret= iso_dir_iter_next(iter, &node);
if(ret < 0) {
Xorriso_report_iso_error(xorriso, "", ret,
"Error when iterating over directory", 0, "FAILURE", 1);
ret= -1; goto ex;
}
if(ret == 0)
break;
if(LIBISO_ISDIR(node) && (flag & 1)) {
ret= Xorriso_dir_disk_path(xorriso, node, disk_path, flag);
if(ret < 0)
goto ex;
if(ret == 0)
continue;
} else if(LIBISO_ISREG(node) && !(flag & 1)) {
ret= Xorriso_retrieve_disk_path(xorriso, node, disk_path, 0);
if(ret < 0)
goto ex;
if(ret == 0)
continue;
} else
continue;
/* Use its parent dir as answer */
npt= strrchr(disk_path, '/');
if(npt == NULL || npt == disk_path)
strcpy(disk_path, "/");
else
*npt= 0;
ret= 1; goto ex;
}
if(!(flag & 1))
ret= Xorriso_dir_disk_path(xorriso, dir_node, disk_path, 1);
else
ret= 0;
ex:
if(iter != NULL)
iso_dir_iter_free(iter);
return(ret);
}
int Xorriso_retrieve_disk_path(struct XorrisO *xorriso, IsoNode *node,
char disk_path[SfileadrL], int flag)
{
IsoFile *file;
IsoStream *stream= NULL, *input_stream;
char type_text[80], *source_path = NULL;
int ret;
if(LIBISO_ISDIR(node)) {
ret= Xorriso_dir_disk_path(xorriso, node, disk_path, 0);
return(ret);
}
if(!LIBISO_ISREG(node))
return(0);