#include <stdio.h> #include <string.h> #include <time.h> #include <sys/stat.h> int getinfo(char *path, char *buf, int bufsize) { int i; struct stat statbuf; int needed; if (stat(path, &statbuf) == -1) return -1; needed = snprintf(buf,bufsize,"%s %lld %lld\n",path, (long long)statbuf.st_mtime, (long long)statbuf.st_size); if (needed >= bufsize) return -1; for (i=0;i<strlen(path);i++) if (buf[i] == ' ') buf[i] = '%'; return 0; }