New functions log_all_partitions() and init_list_part()

This commit is contained in:
Christophe Grenier 2013-05-15 13:53:12 +02:00
parent fd9c697a03
commit e2711613a2
5 changed files with 28 additions and 22 deletions

View file

@ -31,14 +31,21 @@
#include "log_part.h"
#include "intrf.h" /* aff_part_aux */
void log_partition(const disk_t *disk_car, const partition_t *partition)
void log_partition(const disk_t *disk, const partition_t *partition)
{
const char *msg;
char buffer_part_size[100];
msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk_car, partition);
msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk, partition);
log_info("%s",msg);
size_to_unit(partition->part_size, buffer_part_size);
if(partition->info[0]!='\0')
log_info("\n %s, %s", partition->info, buffer_part_size);
log_info("\n");
}
void log_all_partitions(const disk_t *disk, const list_part_t *list_part)
{
list_part_t *element;
for(element=list_part; element!=NULL; element=element->next)
log_partition(disk, element->part);
}

View file

@ -25,7 +25,8 @@
extern "C" {
#endif
void log_partition(const disk_t *disk_car,const partition_t *partition);
void log_partition(const disk_t *disk, const partition_t *partition);
void log_all_partitions(const disk_t *disk, const list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */

View file

@ -1070,4 +1070,17 @@ void status_inc(struct ph_param *params, const struct ph_options *options)
}
}
list_part_t *init_list_part(disk_t *disk, const struct ph_options *options)
{
int insert_error=0;
list_part_t *list_part;
partition_t *partition_wd;
list_part=disk->arch->read_part(disk, (options!=NULL?options->verbose:0), 0);
partition_wd=new_whole_disk(disk);
list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error);
if(insert_error>0)
{
free(partition_wd);
}
return list_part;
}

View file

@ -83,6 +83,7 @@ uint64_t set_search_start(struct ph_param *params, alloc_data_t **new_current_se
void params_reset(struct ph_param *params, const struct ph_options *options);
const char *status_to_name(const photorec_status_t status);
void status_inc(struct ph_param *params, const struct ph_options *options);
list_part_t *init_list_part(disk_t *disk, const struct ph_options *options);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif

View file

@ -99,26 +99,10 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
};
#endif
params->blocksize=0;
list_part=params->disk->arch->read_part(params->disk,options->verbose,0);
{
int insert_error=0;
partition_t *partition_wd;
partition_wd=new_whole_disk(params->disk);
list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error);
if(insert_error>0)
{
free(partition_wd);
}
}
list_part=init_list_part(params->disk, options);
if(list_part==NULL)
return;
{
list_part_t *element;
for(element=list_part;element!=NULL;element=element->next)
{
log_partition(params->disk,element->part);
}
}
log_all_partitions(params->disk, list_part);
if(list_part->next!=NULL)
{
current_element_num=1;