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
|
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int tri(const void *,const void *);
int main (int argc, char *argv[])
{
int i, mode;
int size;
int result;
char * patch=NULL;
char date1[30];
char date2[30];
char date3[30];
struct stat sbuf;
for(i=1; i < argc; i++)
{
result=stat(argv[i], &sbuf);
if(result == 0)
{
mode=sbuf.st_mode;
size=sbuf.st_size;
char string[40];
char * pt = "sbuf.st_size";
//sprintf(string,"%d", (int *)sbuf.st_size);
//printf("%s\n", string);
// strftime (date1,29,"%m/%d/%Y %T", gmtime (&sbuf.st_mtime));
// strftime (date2,29,"%m/%d/%Y %T", gmtime (&sbuf.st_atime));
// strftime (date2,29,"%m/%d/%Y %T", gmtime (&sbuf.st_atime));
// patch=argv[i];
//if(S_ISDIR (mode)) {
//printf ("%12d %s %s %s\n",sbuf.st_size,date1,date2,date3,patch);
//}
//if(S_ISLNK (mode)) printf("%s S File size %ld\n", argv[i],
//if(S_ISREG (mode)) {
//printf("%12d %s %s %s\n",sbuf.st_size,date1,date2,date3,patch);
//}
sprintf(string,"%d", (int *)sbuf.st_size);
qsort((void*)string,40,sizeof(string),tri);
printf("%s\n", string);
}
else
printf("Problem getting information\n");
}
return 0;
}
int tri(const void * a, const void * b) {
return(strcmp(*(int *)a,*(int *)b));
} |