3

I'm using the flock() method to get an advisory lock on a directory, and prevent another process from accessing the same directory at the same time. Because flock() operates on a file handle, I have to open a handle on the directory first:

fopen('.', 'r');

However, this does not work on Windows:

fopen(.): failed to open stream: Permission denied

Is there a way to do the same on Windows, or is it a limitation of this platform?

BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

0

Don't think you can in Windows without a file system driver.

But try to use a file as a reference. Create a file in the folder called .locker and lock/unlock it. If it's locked, means folder should not be touched... otherwise.

Or... use a database to store concurrently accessible data. File disk operations are much slower. This can become a bottleneck for your site's performance.

CodeAngry
  • 12,760
  • 3
  • 50
  • 57