Home » File System » File » Bug #6316
The File_CSV doesn't allow to read data from a file and after write data
Details
| 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 |
Comments
[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; <<----
..............................................