New command -file_name_limit, -as mkisofs -file_name_limit
This commit is contained in:
@ -240,6 +240,7 @@ int Xorriso_node_get_dev(struct XorrisO *xorriso, IsoNode *node,
|
||||
bit3= stbuf is to be used without eventual ACL
|
||||
bit4= try to obtain a better st_nlink count if hardlinks
|
||||
are enabled
|
||||
bit5= do not look for truncated versions of path component
|
||||
*/
|
||||
int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
IsoNode **node, int flag)
|
||||
@ -257,7 +258,8 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret<=0)
|
||||
return(-1);
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, node, !(flag&4));
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, node,
|
||||
((flag >> 4) & 2) | !(flag&4));
|
||||
if(ret<=0)
|
||||
*node= NULL;
|
||||
}
|
||||
@ -1587,10 +1589,91 @@ int Xorriso_node_eff_hidden(struct XorrisO *xorriso, IsoNode *node, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= do not truncate components which contain any of "*?["
|
||||
*/
|
||||
int Xorriso_truncate_path_comps(struct XorrisO *xorriso, char *path,
|
||||
char *buffer, char **resultpt, int flag)
|
||||
{
|
||||
char *rpt, *basrpt, *wpt, *baswpt, *cpt;
|
||||
int ended, ret, skip;
|
||||
|
||||
*resultpt= path;
|
||||
|
||||
/* Check component lengths */
|
||||
rpt= path;
|
||||
if(*rpt == '/')
|
||||
rpt++;
|
||||
for(ended= 0; !ended;) {
|
||||
basrpt= rpt;
|
||||
rpt= strchr(basrpt, '/');
|
||||
if(rpt == NULL) {
|
||||
rpt= basrpt + strlen(basrpt);
|
||||
ended= 1;
|
||||
}
|
||||
skip= 0;
|
||||
if(flag & 1) {
|
||||
for(cpt= basrpt; cpt < rpt; cpt++) {
|
||||
if(strchr("*?[", *cpt) != NULL) {
|
||||
skip= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if((!skip) && rpt - basrpt > xorriso->file_name_limit) {
|
||||
ended= 0;
|
||||
break;
|
||||
}
|
||||
if(*rpt == '/')
|
||||
rpt++;
|
||||
}
|
||||
if(ended)
|
||||
return(1); /* All short enough */
|
||||
|
||||
/* Some truncation is needed */
|
||||
buffer[0]= 0;
|
||||
wpt= buffer;
|
||||
if(path[0] == '/')
|
||||
*(wpt++)= '/';
|
||||
rpt= path;
|
||||
if(*rpt == '/')
|
||||
rpt++;
|
||||
for(ended= 0; !ended;) {
|
||||
basrpt= rpt;
|
||||
baswpt= wpt;
|
||||
rpt= strchr(basrpt, '/');
|
||||
if(rpt == NULL) {
|
||||
rpt= basrpt + strlen(basrpt);
|
||||
ended= 1;
|
||||
}
|
||||
skip= 0;
|
||||
for(cpt= basrpt; cpt < rpt; cpt++) {
|
||||
*(wpt++)= *cpt;
|
||||
if((flag & 1) && strchr("*?[", *cpt) != NULL)
|
||||
skip= 1;
|
||||
}
|
||||
*wpt= 0;
|
||||
if((!skip) && rpt - basrpt > xorriso->file_name_limit) {
|
||||
ret= iso_truncate_leaf_name(1, xorriso->file_name_limit, baswpt, 0);
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
if(ret < 0)
|
||||
return(0);
|
||||
wpt= baswpt + strlen(baswpt);
|
||||
}
|
||||
if(!ended) {
|
||||
*(wpt++)= '/';
|
||||
rpt++;
|
||||
}
|
||||
}
|
||||
*resultpt= buffer;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= long format
|
||||
bit1= do not print count of nodes
|
||||
bit2= du format
|
||||
bit3= print directories as themselves (ls -d)
|
||||
bit5= do not look for truncated versions of path component
|
||||
*/
|
||||
int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
int filec, char **filev, off_t boss_mem, int flag)
|
||||
@ -1599,7 +1682,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
IsoNode *node;
|
||||
IsoImage *volume;
|
||||
char *path= NULL, *link_target= NULL, *rpt, **dfilev= NULL;
|
||||
char *a_text= NULL, *d_text= NULL;
|
||||
char *a_text= NULL, *d_text= NULL, *namept;
|
||||
off_t size;
|
||||
struct stat stbuf;
|
||||
|
||||
@ -1621,7 +1704,8 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
was_error++;
|
||||
continue;
|
||||
}
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1);
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, &node,
|
||||
1 | ((flag >> 4) & 2));
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "Not found in ISO image: ");
|
||||
Text_shellsafe(path, xorriso->info_text, 1);
|
||||
@ -1670,7 +1754,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
Xorriso_ls_filev(xorriso, path,
|
||||
dfilec, dfilev, boss_mem, (flag&1)|2|8);
|
||||
dfilec, dfilev, boss_mem, (flag & 1) | 2 | 8);
|
||||
}
|
||||
if(dfilec>0)
|
||||
Sfile_destroy_argv(&dfilec, &dfilev, 0);
|
||||
@ -1708,12 +1792,13 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
else
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
}
|
||||
Xorriso_truncate_path_comps(xorriso, filev[i], path, &namept, 0);
|
||||
if(link_target[0] && (flag&5)==1) {
|
||||
Xorriso_esc_filepath(xorriso, filev[i], xorriso->result_line, 1),
|
||||
Xorriso_esc_filepath(xorriso, namept, xorriso->result_line, 1);
|
||||
strcat(xorriso->result_line, " -> ");
|
||||
Xorriso_esc_filepath(xorriso, link_target, xorriso->result_line, 1 | 2);
|
||||
} else {
|
||||
Xorriso_esc_filepath(xorriso, filev[i], xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso, namept, xorriso->result_line, 1);
|
||||
}
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
@ -2470,7 +2555,9 @@ int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node,
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0=do not complain about non existent node */
|
||||
/* @param flag bit0=do not complain about non existent node
|
||||
bit1= do not try to find truncated name first
|
||||
*/
|
||||
int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
|
||||
char *path, IsoNode **node, int flag)
|
||||
{
|
||||
@ -2486,7 +2573,11 @@ int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
|
||||
return(ret);
|
||||
}
|
||||
*node= NULL;
|
||||
ret= iso_tree_path_to_node(volume, path_pt, node);
|
||||
ret= 2;
|
||||
if(!(flag & 2))
|
||||
ret= iso_image_path_to_node(volume, path_pt, node);
|
||||
if(ret == 2)
|
||||
ret= iso_tree_path_to_node(volume, path_pt, node);
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(ret<=0 || (*node)==NULL) {
|
||||
if(!(flag&1)) {
|
||||
@ -2501,6 +2592,9 @@ int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0=do not complain about non existent node
|
||||
bit1= do not try to find truncated name first
|
||||
*/
|
||||
int Xorriso_dir_from_path(struct XorrisO *xorriso, char *purpose,
|
||||
char *path, IsoDir **dir_node, int flag)
|
||||
{
|
||||
@ -2512,7 +2606,7 @@ int Xorriso_dir_from_path(struct XorrisO *xorriso, char *purpose,
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, &node, 0);
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, &node, flag & 3);
|
||||
if(ret<=0)
|
||||
goto wdi_is_not_a_dir;
|
||||
if(LIBISO_ISDIR(node))
|
||||
|
Reference in New Issue
Block a user