Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windows - locking files

Started by MutteringGoblin Apr 21, 2003 at 11:16 PM 3 replies 350+ views
Original Post
MutteringGoblin
MutteringGoblin
Hi, I''m writing a class to wrap the WinAPI file functions. (I''ve never actually used them, but they don''t look very nice so I''d like to get them out of the way). Anyway the question is: should I use LockFile to lock files for the whole time they are in use, or not? The API documentation isn''t very clear on the subject. Thanks
Nytegard
Nytegard
It really depends on whether you want the user to be able to access the file while your program is running.

If you were writing a word processor for example, maybe the user might want to use the files you opened in another application or process. In this case, I wouldn''t lock the files.

On the other hand, if your program required a pristine condition from the file (such as loading a save game), and a corrupt file could cause problems (crashes, invalid data, etc), you might want to lock the file.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.