The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
It's basically a log file. I probably could do it using a database but I would really prefer not to. I was just wondering if there was any normal way of opening a file so that one user can use it at a time and waits for the file to be freed up. The function I wrote to get a handle of a file for writing is as such:
function waitforfilehandle_write($path)
{
//echo "$path
\n";
$RetVal = -1;
if (file_exists($path))
{
$success = 0;
while ($success==0)
{
if (is_writable($path))
{
$handle = @fopen($path, 'w');
if ($handle && flock($handle,LOCK_EX))
{
$RetVal = $handle;
$success = 1;
}
else
{
fclose($handle);
}
}
}
}
else
{
echo "ERROR 908 - WaitForFileHandle_Write has no file";
}
return $RetVal;
}
When you say "write to a file", what exactly is being written?
You could probably do with a database instead...