New command -concat

This commit is contained in:
2014-04-21 13:18:38 +00:00
parent 8d4867c9a4
commit 642ec7ca89
17 changed files with 712 additions and 129 deletions

View File

@ -2,7 +2,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2012 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2014 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -55,6 +55,9 @@ int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource)
}
/* @param flag bit0= open IsoNode *node_pt rather than looking up pathname
bit1= dig out the most original stream for reading
*/
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
void *node_pt, void **stream, int flag)
{
@ -242,6 +245,58 @@ int Xorriso_restore_is_identical(struct XorrisO *xorriso, void *in_node,
}
int Xorriso_iso_file_to_fd(struct XorrisO *xorriso, char *path, int fd,
int flag)
{
int ret, rret, wret, to_write, wanted;
void *stream= NULL;
char *buffer= NULL, *wpt;
off_t todo;
static int buffer_size= 64 * 1024;
Xorriso_alloc_meM(buffer, char, buffer_size);
ret= Xorriso_iso_file_open(xorriso, path, NULL, &stream, 0);
if(ret <= 0)
goto ex;
todo= iso_stream_get_size((IsoStream *) stream);
while(todo > 0) {
if(todo < buffer_size)
wanted= todo;
else
wanted= buffer_size;
rret = Xorriso_iso_file_read(xorriso, stream, buffer, wanted, 0);
if(rret <= 0)
{ret= -1; goto ex;}
todo-= rret;
wpt= buffer;
for(to_write= rret; to_write > 0;) {
wret= write(fd, wpt, to_write);
if(wret <= 0) {
if(wret == 0)
sprintf(xorriso->info_text,
"Strange behavior of write(2): return == 0 with ");
else
sprintf(xorriso->info_text, "Write error with ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text,
wret == 0 ? 0 : errno, "FAILURE",0);
ret= 0; goto ex;
}
to_write-= wret;
wpt+= wret;
}
}
ret= 1;
ex:;
if(stream != NULL)
Xorriso_iso_file_close(xorriso, &stream, 0);
Xorriso_free_meM(buffer);
return(ret);
}
/* @param flag bit0= minimal transfer: access permissions only
bit1= keep directory open: keep owner, allow rwx for owner
and push directory onto xorriso->perm_stack