File Sync problem
BlitzMax Forums/BlitzMax Programming/File Sync problem
| ||
Hi all, I'm working on a file sync app and what I want to be able to do is update the destination folder when any file is changed in the source folder. I tried using the FileTime() to compare the file dates . The problem is however that when I use copyfile() the new file always has the current time and not the time of the original. So subsequent compare will always flag the original file as a recent update even though it was just updated. Is there a better way to tackle this problem? Thanks for all the help. |
| ||
Don't use exact match, use "if source file time is BIGGER then sync" Pseudo code: SourceFile time = 1001 DestinationFile time = 900 Compare times: - since sourceFile time (1001) IS BIGGER DestinationFile time (900) => make a copyfile, now times are: SourceFile time (1001) DestinationFile time (2009) Compare times: - since sourceFile time (1001) IS NOT BIGGER than DestinationFile time (2009) => do nothing |
| ||
if you have folder A(source) and folder B(dest) and you never want to copy/sync changes from B to A, then you could possibly just use hashing. hash a file in A and if that hash is different from the same file in B then you can 'assume' a change has happened in A (again assuming you aren't updating files in B separately). example code to hash files can be found here that's just another way of approaching it :). |
| ||
Thanks a lot guys. That solves my problem. |