#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//
// get file modify time
//
char* getModifyTime(char *path)
{
FILE *fp;
unsigned int chk=0, i=0;
char tmp[200],cmd[100],c;
char *out;
sprintf(cmd, "stat %s | grep Modify: > /tmp/msgLogFile", path);
system(cmd);
fp = fopen("/tmp/msgLogFile", "r");
if(!fp) exit(1);
while((c=getc(fp))!=EOF)
{
if(i>7)
tmp[chk++] = c;
else
i++;
}
tmp[chk-1]='\0';
out = (char*)malloc(strlen(tmp));
strcpy(out, tmp);
return out;
}
int main(void)
{
char *time;
time = getModifyTime("./messages");
printf("%s \n", time);
free(time);
return 1;
}
#include <stdlib.h>
#include <string.h>
//
// get file modify time
//
char* getModifyTime(char *path)
{
FILE *fp;
unsigned int chk=0, i=0;
char tmp[200],cmd[100],c;
char *out;
sprintf(cmd, "stat %s | grep Modify: > /tmp/msgLogFile", path);
system(cmd);
fp = fopen("/tmp/msgLogFile", "r");
if(!fp) exit(1);
while((c=getc(fp))!=EOF)
{
if(i>7)
tmp[chk++] = c;
else
i++;
}
tmp[chk-1]='\0';
out = (char*)malloc(strlen(tmp));
strcpy(out, tmp);
return out;
}
int main(void)
{
char *time;
time = getModifyTime("./messages");
printf("%s \n", time);
free(time);
return 1;
}
'Linux' 카테고리의 다른 글
proc (procfs) (0) | 2013.09.26 |
---|---|
file (0) | 2013.09.26 |
[tip] vim (0) | 2013.09.26 |
[source] my bashrc file (0) | 2013.09.26 |
[command] 마운트(mount) (0) | 2013.09.26 |