CVS update: /cowiki/includes/cowiki/class/io/

[email protected] 8 Jun 2005 13:50:03 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/06/08 06:50:03

Modified:
   cowiki/includes/cowiki/class/io/class.FileOutputStream.php

Log:
 If locking strategy is 'STD' (standard) and we are running on Windows, we force the strategy to be 'FILE' which will use a .lock file to emulate a lock
 This fixes an error on Windows platforms as the flock() function would always return "false" if STD (standard) mode is required. Hence every lock() invocation in "STD" mode on Windows has failed.

File Changes:

Directory: /cowiki/includes/cowiki/class/io/
============================================

File [changed]: class.FileOutputStream.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/io/class.FileOutputStream.php?r1=1.15&r2=1.16
Delta lines:  +13 -2
--------------------
--- class.FileOutputStream.php	28 Apr 2005 01:20:52 -0000	1.15
+++ class.FileOutputStream.php	8 Jun 2005 13:50:01 -0000	1.16
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.FileOutputStream.php,v 1.15 2005/04/28 01:20:52 dgorski Exp $
+ * $Id: class.FileOutputStream.php,v 1.16 2005/06/08 13:50:01 dgorski Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.15 $
+ * @version     $Revision: 1.16 $
  *
  */
 
@@ -65,6 +65,17 @@
         $this->sLockType = $sLockType;
 
         if (is_string($mOut)) {
+
+            // If locking strategy is 'STD' (standard) and we are running
+            // on Windows, we force the strategy to be 'FILE' which will
+            // use a .lock file to emulate a lock.
+            $bForceDotLock = strpos(strtolower(PHP_OS), 'win') === true;
+
+            if ($this->sLockType == 'STD' && $bForceDotLock) {
+                $this->sLockType = 'FILE';
+            }
+
+            // ---
 
             // {{{ DEBUG }}}
             Logger::io('Trying to open for writing "'.$mOut.'"');