From 4f144f2662af4f630a7bdc76970e987a178ba597 Mon Sep 17 00:00:00 2001 From: William Knauss Date: Sat, 11 Jul 2015 13:15:34 -0400 Subject: [PATCH] Addresses #62 --- parsecsv.lib.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/parsecsv.lib.php b/parsecsv.lib.php index 83105d1..42cd40a 100644 --- a/parsecsv.lib.php +++ b/parsecsv.lib.php @@ -1147,9 +1147,17 @@ class parseCSV { * * @return true or false */ - protected function _wfile($file, $string = '') { - file_put_contents($file, $string); + protected function _wfile($file, $string = '', $mode = 'wb', $lock = 2) { + if ($fp = fopen($file, $mode)) { + flock($fp, $lock); + $re = fwrite($fp, $string); + $re2 = fclose($fp); - return true; + if ($re != false && $re2 != false) { + return true; + } + } + + return false; } }