Yes sorry.
Here is the whole function. address="../" in my example :
Code:
void createLog(char * address){
FILE *fp;
struct stat sb;
struct dirent *lecture;
if(stat(address, &sb) == -1)
{
perror("there is no such directory");
exit(EXIT_FAILURE);
}
printf("Last status change: %s", ctime(&sb.st_ctime));
printf("Last file access: %s", ctime(&sb.st_atime));
printf("Last file modification: %s", ctime(&sb.st_mtime));
fp = fopen("server.log", "w+");
// take the address and open directory
DIR *rep = opendir (address);
while ((lecture = readdir (rep)))
{
stat (lecture->d_name, &sb);
if(strcmp(lecture->d_name,".")!=0 && strcmp(lecture->d_name,"..")!=0)
{
time_t t = sb.st_mtime;
struct tm tm = *localtime (&t);
char s[32];
strftime (s, sizeof s, "%d/%m/%Y %H:%M:%S", &tm);
printf ("%-14s %s", lecture->d_name, s);
fprintf(fp, "%s %s\n", lecture->d_name, s);
printf("\n");
}
}
printf("either file was created or edited again...\n");
fclose(fp);
}
The function createLog(char...) is used at the beginning of the program and when it receives a signal from the client, it executes the modifyAttributes function.