Working towards coordination of -compare, -update and -cut_out

This commit is contained in:
Thomas Schmitt 2008-03-22 13:00:38 +00:00
parent b0ac8b67ae
commit 07b54e308a
5 changed files with 228 additions and 1 deletions

View File

@ -2720,6 +2720,125 @@ int Findjob_set_action_subjob(struct FindjoB *o, int action,
}
/* ---------------------------- SplitparT ------------------------- */
struct SplitparT {
char *name;
int partno;
int total_parts;
off_t offset;
off_t bytes;
off_t total_bytes;
};
int Splitparts_new(struct SplitparT **o, int count, int flag)
{
int i;
(*o)= TSOB_FELD(struct SplitparT, count);
if((*o)==NULL)
return(-1);
for(i= 0; i<count; i++) {
o[i]->name= NULL;
o[i]->partno= 0;
o[i]->total_parts= 0;
o[i]->offset= 0;
o[i]->bytes= 0;
o[i]->total_bytes= 0;
}
return(1);
}
int Splitparts_destroy(struct SplitparT **o, int count, int flag)
{
int i;
if((*o)==NULL)
return(0);
for(i= 0; i<count; i++) {
if(o[i]->name!=NULL)
free(o[i]->name);
}
free(*o);
*o= NULL;
return(1);
}
int Splitpart_set(struct SplitparT *o, char *name, int partno, int total_parts,
off_t offset, off_t bytes, off_t total_bytes, int flag)
{
o->name= name;
o->partno= partno;
o->total_parts= total_parts;
o->offset= offset;
o->bytes= bytes;
o->total_bytes= total_bytes;
return(1);
}
int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
int flag)
{
char *cpt, *ept, scale[4];
*num= 0;
for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++);
if(*cpt==0)
return(0);
for(ept= cpt; *ept!=0 && isdigit(*ept); ept++)
*num= (*num)*10+(*ept)-'0';
scale[0]= '1';
scale[1]= *ept;
scale[2]= 0;
*num *= (off_t) Scanf_io_size(scale, 0);
if(*ept!=0)
ept++;
*next_pt= ept;
return(1);
}
int Splitpart__parse(char *name, int *partno, int *total_parts,
off_t *offset, off_t *bytes, off_t *total_bytes, int flag)
{
int ret;
off_t num;
char *cpt, *ept;
cpt= name;
ret= Splitpart__read_next_num(name, &ept, &num, 0);
if(ret<=0)
return(ret);
*partno= num;
cpt= ept;
ret= Splitpart__read_next_num(name, &ept, &num, 0);
if(ret<=0)
return(ret);
*total_parts= num;
cpt= ept;
ret= Splitpart__read_next_num(name, &ept, offset, 0);
if(ret<=0)
return(ret);
cpt= ept;
ret= Splitpart__read_next_num(name, &ept, bytes, 0);
if(ret<=0)
return(ret);
cpt= ept;
ret= Splitpart__read_next_num(name, &ept, total_bytes, 0);
if(ret<=0)
return(ret);
return(1);
}
/* ---------------------------- End SplitparT ------------------------- */
/* ------------------------------- Xorriso -------------------------------- */
/** The list of startup file names */
@ -4222,6 +4341,7 @@ much_too_long:;
return(1);
}
/*
@param result Bitfield indicationg type of mismatch
bit0= disk_adr not existing

View File

@ -427,5 +427,17 @@ int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag);
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag);
struct SplitparT;
int Splitparts_new(struct SplitparT **o, int count, int flag);
int Splitparts_destroy(struct SplitparT **o, int count, int flag);
int Splitpart_set(struct SplitparT *o, char *name, int partno, int total_parts,
off_t offset, off_t bytes, off_t total_bytes, int flag);
int Splitpart__parse(char *name, int *partno, int *total_parts,
off_t *offset, off_t *bytes, off_t *total_bytes, int flag);
#endif /* Xorriso_private_includeD */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.03.20.210522"
#define Xorriso_timestamP "2008.03.22.130031"

View File

@ -4833,3 +4833,93 @@ int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
}
int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
struct SplitparT **parts, int *count, int flag)
{
int ret, i;
int partno, total_parts, first_total_parts= -1;
off_t offset, bytes, total_bytes, first_total_bytes= -1;
IsoImage *volume;
IsoDir *dir_node;
IsoDirIter *iter= NULL;
IsoNode *node;
char *name;
struct stat stbuf, first_stbuf;
*count= 0;
*parts= NULL;
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(-1);
ret= Xorriso_node_from_path(xorriso, volume, iso_adr, &node, 1);
if(ret<=0)
return(-1);
if(!LIBISO_ISDIR(node))
return(0);
dir_node= (IsoDir *) node;
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
cannot_iter:;
Xorriso_cannot_create_iter(xorriso, ret, 0);
return(-1);
}
for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) {
name= (char *) iso_node_get_name(node);
ret= Splitpart__parse(name, &partno, &total_parts,
&offset, &bytes, &total_bytes, 0);
if(ret<=0)
{ret= 0; goto ex;}
if(i==0) {
first_total_parts= total_parts;
first_total_bytes= total_bytes;
Xorriso_fake_stbuf(xorriso, "", &first_stbuf, &node, 1);
} else {
if(first_total_parts!=total_parts || first_total_bytes!=total_bytes)
{ret= 0; goto ex;}
Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(first_stbuf.st_mode != stbuf.st_mode ||
first_stbuf.st_uid != stbuf.st_uid ||
first_stbuf.st_gid != stbuf.st_gid ||
first_stbuf.st_mtime != stbuf.st_mtime ||
first_stbuf.st_ctime != stbuf.st_ctime ||
first_stbuf.st_atime != stbuf.st_atime)
{ret= 0; goto ex;}
}
(*count)++;
}
if((*count)<=0)
{ret= 0; goto ex;}
ret= Splitparts_new(parts, (*count)+1, 0); /* (have one end marker item) */
if(ret<=0)
return(ret);
iso_dir_iter_free(iter);
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0)
goto cannot_iter;
for(i= 0; i<*count; i++) {
name= (char *) iso_node_get_name(node);
ret= Splitpart__parse(name, &partno, &total_parts,
&offset, &bytes, &total_bytes, 0);
if(ret<=0)
{ret= 0; goto ex;}
Splitpart_set(parts[i], name, partno, total_parts, offset, bytes,
total_bytes, 0);
}
/* >>> ??? sort list ? */
/* >>> check for equal frequency */;
/* >>> check for disjointness */
/* >>> check for plausible size */
ret= 1;
ex:;
if(iter!=NULL)
iso_dir_iter_free(iter);
return(ret);
}

View File

@ -195,5 +195,10 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path,
off_t startbyte, off_t bytecount, char *iso_rr_path, int flag);
struct SplitparT;
int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
struct SplitparT **parts, int *count, int flag);
#endif /* Xorrisoburn_includeD */