Narrowed rules for recognizing split file parts

This commit is contained in:
Thomas Schmitt 2009-09-27 08:04:05 +00:00
parent f02a22eba0
commit 8ec9dd6a05
4 changed files with 101 additions and 48 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Sep 19, 2009"
.TH XORRISO 1 "Sep 25, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -994,30 +994,11 @@ E.g:
.br
/file/part_3_of_3_at_4094m_with_2047m_of_5753194821
.br
-cut_out is coordinated with -compare* and -update* if the names of the
part files follow a convention by which xorriso is able to recognize
file parts and process them accordingly:
.br
A disk file gets mapped to an ISO directory containing its split parts
as regular files. The parts have names which describe the splitting
by 5 numbers which are separated by some non-numerical text:
.br
part_number, total_parts, byte_offset, byte_count, disk_file_size
.br
Scaling characters like "m" or "k" are taken into respect and may
serve as separators as well. All digits are interpreted as decimal,
even if leading zeros are present.
.br
Not all parts have to be present on the same media. But those parts
which are present have to sit in the same directory. No other files
are allowed in there. Parts have to be disjoint. Their numbers have
to be plausible. E.g. byte_count must be valid as -cut_out argument
and it must be the same with all parts.
.br
If the disk file grows enough to need new parts then those get added
to the directory if it already contains all parts of the old disk file.
If not all parts are present, then only those present parts will
be updated.
While option -split_size is set larger than 0 such file pieces will be
recognized by their peculiar names. They get handled by options -compare* and
-update*. In overwrite situations the common parent directory will be handled
like a regular file, if it contains exactly one complete set of file parts.
See option -split_size for details.
.TP
\fB\-cpr\fR disk_path [***] iso_rr_path
Insert the given files or directory trees from filesystem
@ -1806,12 +1787,45 @@ maps a large disk file onto a ISO directory with several part files in it.
This is necessary if the size of the disk file exceeds -file_size_limit.
Older operating systems can handle files in mounted ISO 9660 filesystems
only if they are smaller than 2 GiB resp. 4 GiB.
See also option -cut_out for more information about file parts.
.br
Default is 0 which will exclude files larger than -file_size_limit by a
FAILURE event.
A well tested -split_size is 2047m. Sizes above -file_size_limit are not
permissible.
.br
While option -split_size is set larger than 0 such file pieces will be
recognized and handled by options -compare* and -update*. In overwrite
situations, the common parent directory will be handled like a regular file
if it contains only one complete set of file parts.
.br
In order to be recognizable, the names of the part files have to follow
a convention:
.br
A disk file gets mapped to an ISO directory containing its split parts
as regular files. The parts have names which describe the splitting
by 5 numbers
.br
part_number,total_parts,byte_offset,byte_count,disk_file_size
.br
which are embedded in the following text form:
.br
part_#_of_#_at_#_with_#_of_#
.br
Scaling characters like "m" or "k" are taken into respect.
All digits are interpreted as decimal, even if leading zeros are present.
.br
E.g: /file/part_1_of_3_at_0_with_2047m_of_5753194821
.br
For -update* and -compar* not all parts have to be present on the same media.
But those parts which are present have to sit in the same directory.
No other files are allowed in there. Parts have to be disjoint. Their numbers
have to be plausible. E.g. byte_count must be valid as -cut_out argument
and it must be the same with all parts.
.br
If the disk file grows enough to need new parts then those get added
to the directory if it already contains all parts of the old disk file.
If not all parts are present, then only those present parts will
be updated.
.TP
.B Settings for result writing:
.TP

View File

@ -3619,6 +3619,8 @@ struct SplitparT {
off_t total_bytes;
};
static char Splitpart_wordS[][16]= {"part_", "_of_", "_at_", "_with_", "_of_"};
int Splitparts_new(struct SplitparT **o, int count, int flag)
{
@ -3691,6 +3693,7 @@ int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
int flag)
{
char *cpt, *ept, scale[4];
double sfak;
*num= 0;
for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++);
@ -3701,8 +3704,9 @@ int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
scale[0]= '1';
scale[1]= *ept;
scale[2]= 0;
*num *= (off_t) Scanf_io_size(scale, 0);
if(*ept!=0)
sfak= Scanf_io_size(scale, 0);
*num *= (off_t) sfak;
if(sfak > 1.0)
ept++;
*next_pt= ept;
return(1);
@ -3718,27 +3722,39 @@ int Splitpart__parse(char *name, int *partno, int *total_parts,
char *cpt, *ept;
cpt= name;
if(strncmp(cpt, Splitpart_wordS[0], strlen(Splitpart_wordS[0])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
if(ret<=0)
return(ret);
*partno= num;
cpt= ept;
if(strncmp(cpt, Splitpart_wordS[1], strlen(Splitpart_wordS[1])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
if(ret<=0)
return(ret);
*total_parts= num;
cpt= ept;
if(strncmp(cpt, Splitpart_wordS[2], strlen(Splitpart_wordS[2])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, offset, 0);
if(ret<=0)
return(ret);
cpt= ept;
if(strncmp(cpt, Splitpart_wordS[3], strlen(Splitpart_wordS[3])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, bytes, 0);
if(ret<=0)
return(ret);
cpt= ept;
if(strncmp(cpt, Splitpart_wordS[4], strlen(Splitpart_wordS[4])) != 0)
return(0);
ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0);
if(ret<=0)
return(ret);
if(*ept != 0)
return(0);
return(1);
}
@ -3752,28 +3768,33 @@ int Splitpart__is_part_path(char *path, int flag)
name= strrchr(path, '/');
if(name == NULL)
name= path;
else
name++;
ret= Splitpart__parse(name, &partno, &total_parts, &offset, &bytes,
&total_bytes, 0);
return(ret > 0);
}
/* part_#_of_#_at_#_with_#_of_#
*/
int Splitpart__compose(char *adr, int partno, int total_parts,
off_t offset, off_t bytes, off_t total_bytes, int flag)
{
sprintf(adr, "part_%d_of_%d_at_", partno, total_parts);
sprintf(adr, "%s%d%s%d%s", Splitpart_wordS[0], partno, Splitpart_wordS[1],
total_parts, Splitpart_wordS[2]);
if((offset % (1024*1024))==0 && offset>0) {
Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0);
strcat(adr, "m");
} else
Sfile_off_t_text(adr+strlen(adr), offset, 0);
strcat(adr, "_with_");
strcat(adr, Splitpart_wordS[3]);
if((bytes % (1024*1024))==0) {
Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0);
strcat(adr, "m");
} else
Sfile_off_t_text(adr+strlen(adr), bytes, 0);
strcat(adr, "_of_");
strcat(adr, Splitpart_wordS[4]);
Sfile_off_t_text(adr+strlen(adr), total_bytes, 0);
return(1);
}
@ -19815,6 +19836,10 @@ next_command:;
} else if(strcmp(cmd,"test")==0) { /* This option does not exist. */
/* install temporary test code here */;
(*idx)++;
fprintf(stderr, "xorriso_DEBUG: Xorriso_is_split(%s)= %d\n",
arg1, Xorriso_is_split(xorriso, arg1, NULL, 2));
} else if(strcmp(cmd,"toc")==0) {
Xorriso_option_toc(xorriso, 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.09.22.143534"
#define Xorriso_timestamP "2009.09.27.080401"

View File

@ -2705,7 +2705,6 @@ int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume,
if(ret<0)
return(ret);
*node= (IsoNode *) new_dir;
total_parts= size / xorriso->split_size;
if(size % xorriso->split_size)
total_parts++;
@ -2767,7 +2766,6 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
node, 0);
if(ret<=0)
goto ex;
return(1);
} else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
sprintf(xorriso->info_text,
"File exceeds size limit of %.f bytes: %s\n",
@ -2775,11 +2773,12 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
} else {
ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node);
if(ret<0)
goto ex;
}
}
if(stbuf_valid && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) {
ret= Xorriso_record_dev_inode(xorriso, disk_path,
@ -2804,6 +2803,7 @@ ex:;
/* @param flag bit0= recursion is active
bit1= do not report added files
bit6= do not delete eventually existing node from di_array
bit7= no special handling of split file directories
*/
int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
char *img_dir_path, char *disk_dir_path,
@ -2955,8 +2955,8 @@ cannot_lstat:;
if(ret>0) {
target_is_dir= LIBISO_ISDIR(node);
target_is_split= 0;
if(target_is_dir)
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1);
if(target_is_dir && !(flag & 128))
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1 | 2);
if(!((target_is_dir && !target_is_split) && source_is_dir)) {
Xorriso_process_msg_queues(xorriso,0);
@ -3014,7 +3014,7 @@ cannot_lstat:;
} else {
ret= Xorriso_add_tree(xorriso, (IsoDir *) node,
img_path, disk_path, own_link_stack,
1 | (flag & (2 | 64)));
1 | (flag & (2 | 64 | 128)));
}
if(ret<=0)
goto was_problem;
@ -3258,8 +3258,8 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
target_is_dir= LIBISO_ISDIR(node);
target_is_split= 0;
if(target_is_dir && !(flag&128))
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1);
if(target_is_dir && !(flag & 128))
target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1 | 2);
if(!((target_is_dir && !target_is_split) && source_is_dir)) {
Xorriso_process_msg_queues(xorriso,0);
@ -3325,7 +3325,7 @@ attach_source:;
(IsoNode *) dir, 4 | 32);
if(!(flag&32)) {
ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL,
flag & (2 | 64));
flag & (2 | 64 | 128));
if(ret<=0)
return(ret);
}
@ -8033,7 +8033,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
void *dir_node_generic, char *dir_path,
struct stat *dir_stbuf, int depth, int flag)
{
int ret, action= 0, hflag, deleted= 0, no_dive= 0;
int ret, action= 0, hflag, deleted= 0, no_dive= 0, split_flag;
IsoDirIter *iter= NULL;
IsoDir *dir_node= NULL;
IsoNode *node, *iso_node;
@ -8128,7 +8128,10 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
}
if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node))
{ret= 1; goto ex;}
if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, 1)>0)
split_flag= 1 | 2;
if(action == 14 || action == 17)
split_flag &= ~2;
if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, split_flag)>0)
{ret= 1; goto ex;}
mem= boss_mem;
@ -9236,6 +9239,8 @@ int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
/* @param flag bit0= in_node is valid, do not resolve iso_adr
bit1= insist in complete collection of part files
??? <<< bit2= recognize and parse split parts despite
xorrio->split_size <= 0
*/
int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
void *in_node,
@ -9257,6 +9262,13 @@ int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr,
*count= 0;
*parts= NULL;
/* <<< remove bit1 and hardcode it
flag|= 2;
*/
if(xorriso->split_size <= 0 && !(flag & 4))
return(0);
if(flag&1) {
node= (IsoNode *) in_node;
} else {
@ -9304,12 +9316,14 @@ cannot_iter:;
size= stbuf.st_size;
}
/* check for plausible size */
if(!((partno<total_parts && size==bytes) ||
(partno==total_parts && size<=bytes)))
if(!((partno != total_parts && size == bytes) ||
(partno == total_parts && size <= bytes)))
{ret= 0; goto ex;}
if(offset != first_bytes * (off_t) (partno - 1))
{ret= 0; goto ex;}
(*count)++;
}
if((*count)<=0)
if(*count <= 0 || (*count != first_total_parts && (flag & 2)))
{ret= 0; goto ex;}
ret= Splitparts_new(parts, (*count)+1, 0); /* (have one end marker item) */