I'm using Java's Files.walkFileTree to scan a particular directory periodically for *.csv files and then reading them.
I know that mv is atomic ( at least within the same device ) so 'mv'ing a file shouldn't be a problem in terms of race condition.
If I do a cp instead, does cp first do a copy to a different filename, and then do a atomic mv to the original name ? Or will it cause a race condition by doing a direct read-write ?
I have the same question for extracting files to another directory using tar & gz .
PS. In case the answer is OS-dependent, I am working on CentOS 6. Also if possible can the answer be mentioned for Windows too ?