New pseudo test with -find : -sort_lba which is actually an option
This commit is contained in:
@ -7345,23 +7345,32 @@ int Xorriso__findi_sorted_cmp(const void *p1, const void *p2)
|
||||
bit1= do not perform job->action on resulting node array
|
||||
*/
|
||||
int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
int filec, char **filev, int flag)
|
||||
off_t boss_mem, int filec, char **filev, int flag)
|
||||
{
|
||||
int i, ret;
|
||||
struct FindjoB array_job;
|
||||
struct FindjoB array_job, *proxy_job= NULL, *hindmost= NULL, *hmboss= NULL;
|
||||
struct stat dir_stbuf;
|
||||
IsoNode *node;
|
||||
char abs_path[SfileadrL];
|
||||
off_t mem_needed= 0;
|
||||
|
||||
array_job.start_path= NULL;
|
||||
|
||||
/* <<< */
|
||||
if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */
|
||||
|
||||
/* >>> cannot deal with chained find yet */;
|
||||
|
||||
return(-1);
|
||||
/* array_job replaces the hindmost job in the chain */
|
||||
for(hindmost= job; hindmost->subjob != NULL; hindmost= hindmost->subjob)
|
||||
hmboss= hindmost;
|
||||
if(hmboss == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
memcpy(&array_job, hindmost, sizeof(struct FindjoB));
|
||||
hmboss->subjob= &array_job;
|
||||
proxy_job= job;
|
||||
} else {
|
||||
memcpy(&array_job, job, sizeof(struct FindjoB));
|
||||
proxy_job= &array_job;
|
||||
hindmost= job;
|
||||
}
|
||||
/* >>> if action == find : array_job would need to replace the hindmost */
|
||||
memcpy(&array_job, job, sizeof(struct FindjoB));
|
||||
array_job.start_path= NULL; /* is owned by the original, not by array_job */
|
||||
|
||||
/* Count matching nodes */
|
||||
Xorriso_destroy_node_array(xorriso, 0);
|
||||
@ -7371,14 +7380,37 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
xorriso->node_counter++;
|
||||
continue;
|
||||
}
|
||||
array_job.start_path= filev[i];
|
||||
ret= Xorriso_findi(xorriso, &array_job, NULL, (off_t) 0, NULL,
|
||||
ret= Findjob_set_start_path(proxy_job, filev[i], 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi(xorriso, proxy_job, NULL, boss_mem, NULL,
|
||||
filev[i], &dir_stbuf, 0, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
}
|
||||
if(xorriso->node_counter <= 0)
|
||||
return(1);
|
||||
{ret= 1; goto ex;}
|
||||
|
||||
mem_needed= boss_mem + xorriso->node_counter * sizeof(IsoNode *);
|
||||
if(!(flag &1)) {
|
||||
ret= Xorriso_check_temp_mem_limit(xorriso, mem_needed, 0);
|
||||
if(ret <= 0) {
|
||||
/* Memory curbed : Perform unsorted find jobs */
|
||||
if(hmboss != NULL)
|
||||
hmboss->subjob= hindmost;
|
||||
for(i= 0; i < filec; i++) {
|
||||
ret= Findjob_set_start_path(job, filev[i], 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi(xorriso, job, NULL, boss_mem, NULL,
|
||||
filev[i], &dir_stbuf, 0, 0);
|
||||
if(ret <= 0)
|
||||
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
|
||||
goto ex;
|
||||
}
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy matching nodes into allocated array */
|
||||
xorriso->node_array_size= xorriso->node_counter;
|
||||
@ -7399,8 +7431,10 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
|
||||
continue;
|
||||
}
|
||||
array_job.start_path= filev[i];
|
||||
ret= Xorriso_findi(xorriso, &array_job, NULL, (off_t) 0, NULL,
|
||||
ret= Findjob_set_start_path(proxy_job, filev[i], 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi(xorriso, proxy_job, NULL, mem_needed, NULL,
|
||||
filev[i], &dir_stbuf, 0, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
@ -7409,18 +7443,15 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
Xorriso__findi_sorted_cmp);
|
||||
|
||||
if(flag & 2)
|
||||
return(1);
|
||||
|
||||
/* Perform job->action on xorriso->node_array */;
|
||||
|
||||
/* >>> if action == find : perform action of the hindmost */
|
||||
{ret= 1; goto ex;}
|
||||
|
||||
/* Perform job->action on xorriso->node_array */
|
||||
for(i= 0; i < xorriso->node_counter; i++) {
|
||||
node= xorriso->node_array[i];
|
||||
ret= Xorriso_path_from_node(xorriso, node, abs_path, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
ret= Xorriso_findi_action(xorriso, job, NULL, (off_t) 0,
|
||||
ret= Xorriso_findi_action(xorriso, hindmost, NULL, (off_t) 0,
|
||||
abs_path, abs_path, node, 0, 1);
|
||||
if(ret <= 0)
|
||||
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
|
||||
@ -7429,6 +7460,10 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(hmboss != NULL)
|
||||
hmboss->subjob= hindmost;
|
||||
if(array_job.start_path != NULL)
|
||||
free(array_job.start_path);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user