New option -compare
This commit is contained in:
@ -2858,7 +2858,9 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= *node is already valid */
|
||||
/* @param flag bit0= *node is already valid
|
||||
bit1= add extra block for size estimation
|
||||
*/
|
||||
int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
IsoNode **node, int flag)
|
||||
{
|
||||
@ -2909,7 +2911,7 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
/* >>> stbuf->st_rdev */
|
||||
|
||||
if(LIBISO_ISREG(*node))
|
||||
stbuf->st_size= iso_file_get_size((IsoFile *) *node)+2048;
|
||||
stbuf->st_size= iso_file_get_size((IsoFile *) *node)+ (2048 * !!(flag&2));
|
||||
else
|
||||
stbuf->st_size= 0;
|
||||
|
||||
@ -3054,7 +3056,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
|
||||
if(ret<=0)
|
||||
continue;
|
||||
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 0);
|
||||
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, (flag&4)>>1);
|
||||
if(ret<=0)
|
||||
continue;
|
||||
if(LIBISO_ISDIR(node) && !(flag&(4|8))) {
|
||||
@ -4254,5 +4256,92 @@ int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number,
|
||||
if(*profile_number==0x08 || *profile_number==0x09 || *profile_number==0x0a)
|
||||
return(2);
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
|
||||
void **stream, int flag)
|
||||
{
|
||||
int ret;
|
||||
char eff_path[SfileadrL];
|
||||
IsoNode *node= NULL;
|
||||
IsoFile *filenode= NULL;
|
||||
IsoStream *iso_stream= NULL;
|
||||
|
||||
*stream= NULL;
|
||||
ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
if(!LIBISO_ISREG(node)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Given path does not lead to a regular data file in the image");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
filenode= (IsoFile *) node;
|
||||
iso_stream= iso_file_get_stream(filenode);
|
||||
if(iso_stream==NULL) {
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
sprintf(xorriso->info_text,
|
||||
"Could not obtain source stream of file in the image for reading");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
ret= iso_stream_open(iso_stream);
|
||||
if(ret<0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Could not open data file in the image for reading");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
if(!iso_stream_is_repeatable(iso_stream)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"The data production of the file in the image is one-time only");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
iso_stream_close(iso_stream);
|
||||
return(0);
|
||||
}
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
*stream= iso_stream;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf,
|
||||
int count, int flag)
|
||||
{
|
||||
int ret, rcnt= 0;
|
||||
IsoStream *stream_pt;
|
||||
|
||||
stream_pt= (IsoStream *) stream;
|
||||
|
||||
while(rcnt<count) {
|
||||
ret= iso_stream_read(stream_pt, (void *) (buf+rcnt), (size_t) (count-rcnt));
|
||||
if(ret==0) /* EOF */
|
||||
break;
|
||||
if(ret<0) { /* error */
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
Xorriso_report_iso_error(xorriso, "", ret, "Error on read",
|
||||
0, "FAILURE",1);
|
||||
return(-1);
|
||||
}
|
||||
rcnt+= ret;
|
||||
}
|
||||
return(rcnt);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(*stream==NULL)
|
||||
return(0);
|
||||
ret= iso_stream_close(*stream);
|
||||
if(ret==1)
|
||||
*stream= NULL;
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user