Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Request #6316 The File_CSV doesn't allow to read data from a file and after write data
Submitted: 2005-12-21 19:41 UTC
From: luiz_vieira82 at yahoo dot com dot br Assigned: dufuz
Status: Closed Package: File
PHP Version: 5.0.5 OS: SUSE 9.3
Roadmaps: 1.3.0a1    
Subscription  


 [2005-12-21 19:41 UTC] luiz_vieira82 at yahoo dot com dot br
Description: ------------ I am using the File_CSV class version 1.24. The problem happens when we use the "read" function before the "write" function in the same archive, i mean, if i try to get some data from a file for exemple "test.txt", the "read" function will open the archive in FILE_MODE_READ mode. After this if i try to write in "test.txt" the class will return to me the file pointer used to read the file. Well, as the file was opened for read, we can't write in, so we get a exception. Here is what i did to solve the issue: function getPointer($file, &$conf, $mode = FILE_MODE_READ, $reset = false) { static $resources = array(); static $config; //add a $mode entry in resource array if (isset($resources[$file][$mode])) { <<------ $conf = $config; if ($reset) { fseek($resources[$file][$mode], 0); <<----- } return $resources[$file][$mode]; <<-------- } File_CSV::_conf($error, $conf); if ($error) { return File_CSV::raiseError($error); } $config = $conf; PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $fp = &File::_getFilePointer($file, $mode); PEAR::popErrorHandling(); if (PEAR::isError($fp)) { return File_CSV::raiseError($fp); } $resources[$file][$mode] = $fp; <<---- ..............................................

Comments

 [2006-03-04 04:20 UTC] dufuz
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.