Merge pull request #19 from coling/master
Fix overzealous cleanup of temporary files.
This commit is contained in:
commit
116412c4e0
|
|
@ -604,7 +604,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
||||||
|
|
||||||
$total_worksheets = count($this->_worksheets);
|
$total_worksheets = count($this->_worksheets);
|
||||||
for ($i = 0; $i < $total_worksheets; $i++) {
|
for ($i = 0; $i < $total_worksheets; $i++) {
|
||||||
while ($tmp = $this->_worksheets[$i]->getData()) {
|
while ($tmp = $this->_worksheets[$i]->getData(true)) {
|
||||||
$OLE->append($tmp);
|
$OLE->append($tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -652,16 +652,6 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_storeDataValidity();
|
$this->_storeDataValidity();
|
||||||
}*/
|
}*/
|
||||||
$this->_storeEof();
|
$this->_storeEof();
|
||||||
|
|
||||||
if ( $this->_tmp_file != '' ) {
|
|
||||||
if ( $this->_filehandle ) {
|
|
||||||
fclose($this->_filehandle);
|
|
||||||
$this->_filehandle = '';
|
|
||||||
}
|
|
||||||
@unlink($this->_tmp_file);
|
|
||||||
$this->_tmp_file = '';
|
|
||||||
$this->_using_tmpfile = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -682,7 +672,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
*
|
*
|
||||||
* @return string The data
|
* @return string The data
|
||||||
*/
|
*/
|
||||||
public function getData()
|
public function getData($cleanup = true)
|
||||||
{
|
{
|
||||||
$buffer = 4096;
|
$buffer = 4096;
|
||||||
|
|
||||||
|
|
@ -690,9 +680,8 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
if (isset($this->_data)) {
|
if (isset($this->_data)) {
|
||||||
$tmp = $this->_data;
|
$tmp = $this->_data;
|
||||||
unset($this->_data);
|
unset($this->_data);
|
||||||
$fh = $this->_filehandle;
|
|
||||||
if ($this->_using_tmpfile) {
|
if ($this->_using_tmpfile) {
|
||||||
fseek($fh, 0);
|
fseek($this->_filehandle, 0);
|
||||||
}
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
@ -701,6 +690,19 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
if ($tmp = fread($this->_filehandle, $buffer)) {
|
if ($tmp = fread($this->_filehandle, $buffer)) {
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All data has now been read (both from memory & from file) so we
|
||||||
|
// can now trash the file
|
||||||
|
if ($cleanup) {
|
||||||
|
if ( $this->_filehandle ) {
|
||||||
|
fclose($this->_filehandle);
|
||||||
|
$this->_filehandle = '';
|
||||||
|
}
|
||||||
|
@unlink($this->_tmp_file);
|
||||||
|
$this->_tmp_file = '';
|
||||||
|
$this->_using_tmpfile = false;
|
||||||
|
$this->_datasize = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No data to return
|
// No data to return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue