1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <strings.h>
int tri(void *tab, int nbr, int taille, int (* comp)(const void *, const void *))
{
int i;
for(i=1; i<nbr; i++)
if(comp((char *)tab+i*taille, (char *)tab+(i+1)*taille)>0)
return 0;
return 1;
}
int compar_size(const void * pt_a, const void * pt_b)
{
const struct stat * pt_sa=(const struct stat *)pt_a;
const struct stat * pt_sb=(const struct stat *)pt_b;
return(pt_sa->size > pt_sb->size);
}
int main (int argc, char *argv[])
{
int i, mode;
int j;
int size;
int result;
char * patch=NULL;
char date1[30];
char date2[30];
char date3[30];
char T[40];
struct stat sbuf[40];
for(i=1; i < argc; i++)
{
result=stat(argv[i], &sbuf[i]);
if(result == 0)
{
mode=sbuf[i].st_mode;
size=sbuf[i].st_size;
::::::::
}
}
else
printf("Problem getting information\n");
}
if(tri(sbuf, 40, sizeof(stat), compar_size)
qsort((void *)sbuf,40,sizeof(stat),compar_size);
return 0;
} |
Partager