Guest User

Untitled

a guest
Oct 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. void main(){
  2. struct stat time_buf;
  3. time_t input_timestamp=0;
  4.  
  5. while(1){
  6. if(access( "inpfile.txt", F_OK ) != -1){
  7. sleep(5);
  8. stat("inpfile.txt", &time_buf);
  9. if(time_buf.st_mtime > input_timestamp){
  10. FILE *fpi,*fpo;
  11. long length;
  12. char *buffer=0;
  13. fpi = fopen("inpfile.txt","r");
  14. fseek(fpi,0,SEEK_END);
  15. length=ftell(fpi);
  16. fseek(fpi,0,SEEK_SET);
  17. buffer=(char *)malloc(length);
  18. fread(buffer,1,length,fpi);
  19. fclose(fpi);
  20.  
  21. fpo=fopen("outfile.txt","w+");
  22. fwrite(buffer,sizeof(char),length,fpo);
  23. fclose(fpo);
  24. input_timestamp=time_buf.st_mtime;
  25. }
  26. }
  27. }
  28.  
  29. }
Add Comment
Please, Sign In to add comment