Question about synchronized file access (locking files)

Started by
-1 comments, last by firefly2442 13 years, 10 months ago
I'm going to be writing a program that will be constantly checking a directory for file changes. Once a change has been found, it will save that file via networking to another machine. My question is in regard to issues of locking and synchronization. Let's say I'm checking my documents folder that has many files being changed. If I identify that a file needs to be saved to the network, I don't want to perform a lock on the file because that would prevent other programs from using this file. I want this to essentially run in the background and have minimal influence on the user. If I'm editing a photo for example and perform a lock on the file then it might hang up the program. So my thought was to copy the file to another temporary location and then send it off to the network. However, if the file is changed while copying this wouldn't work. If a program is using a file, does that automatically mean that the file is locked? Does this depend on the operating system or filesystem? What's the best way to go about this? Thanks in advance. :)
http://www.rivetcode.com

This topic is closed to new replies.

Advertisement