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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!