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
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#define PATH "/home/cache"
int
ispng(char *file) {
char tmp[256];
char* p, *token;
bzero(tmp, 256);
strcpy(tmp,file);
token = strtok_r(tmp,".",&p);
fprintf(stderr,"tmp=<%s>, token=<%s>, p=<%s>\n",tmp,token,p);
if(strcmp(p,"png") == 0) {
return 0;
} else {
return 1;
}
}
int
main() {
int rc=0;
DIR* dir=NULL;
struct dirent * ent;
time_t debut,fin,t;
char fileIn[256]=PATH;
char tmp[256];
int chrono=0;
/* ouverture du repertoire ou arrive les captures d'écran */
dir = opendir(PATH);
debut = time(&t);
while(dir != NULL) {
while((ent = readdir(dir)) != NULL) {
if(ispng(ent->d_name) == 0) {
strcat(fileIn,ent->d_name);
strcpy(tmp, ent->d_name);
fprintf(stderr,"fileIn=<%s> tmp=<%s>\n",fileIn,tmp);
}
}
fin = time(&t);
chrono = fin - debut;
if(chrono > 60) {
exit(0);
}
}
return 0;
} |
Partager