Agreed! There is no practical use, because as you point out there's nothing to stop another task from opening the file before action is taken on the result of the test.luis wrote:But what's the practical use for something like this ?
I'm asking because:
Code: Select all
if FileIsClosed ("file.txt") ; ok the file was not in use, some time ago, inside that proc ; but now ? endif
In a shared environment, every task/user has to be working to the same set of rules. This might be a complex file locking protocol that allows files to be updated, shared, and copied, all without data loss. Or it might be something as simple as kicking everyone off the network while files are copied.
I've found that the later solution works well and is simple to implement.
