Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main(){
- struct stat time_buf;
- time_t input_timestamp=0;
- while(1){
- if(access( "inpfile.txt", F_OK ) != -1){
- sleep(5);
- stat("inpfile.txt", &time_buf);
- if(time_buf.st_mtime > input_timestamp){
- FILE *fpi,*fpo;
- long length;
- char *buffer=0;
- fpi = fopen("inpfile.txt","r");
- fseek(fpi,0,SEEK_END);
- length=ftell(fpi);
- fseek(fpi,0,SEEK_SET);
- buffer=(char *)malloc(length);
- fread(buffer,1,length,fpi);
- fclose(fpi);
- fpo=fopen("outfile.txt","w+");
- fwrite(buffer,sizeof(char),length,fpo);
- fclose(fpo);
- input_timestamp=time_buf.st_mtime;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment