Public Member Functions | |
init (Mage_Dataflow_Model_Batch $object) | |
getPath () | |
getFile ($withPath=false) | |
getIoAdapter () | |
open ($write=true) | |
write ($string) | |
read ($csv=false, $delimiter= ',', $enclosure= '"') | |
close () | |
clear () | |
getFileSize () | |
Public Attributes | |
const | TMP_DIR = '/var/tmp/' |
const | TMP_NAME = 'batch_%d.tmp' |
Protected Attributes | |
$_batchModel | |
$_path | |
$_filename | |
$_ioFile | |
$_fileSize = 0 |
Definition at line 35 of file Io.php.
clear | ( | ) |
Definition at line 192 of file Io.php.
00193 { 00194 return $this->getIoAdapter()->rm($this->getFile(true)); 00195 }
close | ( | ) |
Close file
Definition at line 187 of file Io.php.
00188 { 00189 return $this->getIoAdapter()->streamClose(); 00190 }
getFile | ( | $ | withPath = false |
) |
Retrieve tmp filename
Definition at line 106 of file Io.php.
00107 { 00108 if (is_null($this->_filename)) { 00109 $this->_filename = sprintf(self::TMP_NAME, $this->_batchModel->getId()); 00110 } 00111 if ($withPath) { 00112 return $this->getPath() . $this->_filename; 00113 } 00114 return $this->_filename; 00115 }
getFileSize | ( | ) |
getIoAdapter | ( | ) |
Retrieve Io File Adapter
Definition at line 122 of file Io.php.
00123 { 00124 if (is_null($this->_ioFile)) { 00125 $this->_ioFile = new Varien_Io_File(); 00126 } 00127 return $this->_ioFile; 00128 }
getPath | ( | ) |
Retrieve real path to tmp dir
Definition at line 92 of file Io.php.
00093 { 00094 if (is_null($this->_path)) { 00095 $this->_path = $this->getIoAdapter()->getCleanPath(Mage::getBaseDir('tmp')); 00096 $this->getIoAdapter()->checkAndCreateFolder($this->_path); 00097 } 00098 return $this->_path; 00099 }
init | ( | Mage_Dataflow_Model_Batch $ | object | ) |
Init model (required)
Mage_Dataflow_Model_Batch | $object |
Definition at line 81 of file Io.php.
open | ( | $ | write = true |
) |
Open file in stream mode
Definition at line 135 of file Io.php.
00136 { 00137 $mode = $write ? 'w+' : 'r+'; 00138 $ioConfig = array( 00139 'path' => $this->getPath() 00140 ); 00141 $this->getIoAdapter()->setAllowCreateFolders(true); 00142 $this->getIoAdapter()->open($ioConfig); 00143 $this->getIoAdapter()->streamOpen($this->getFile(), $mode); 00144 00145 $this->_fileSize = 0; 00146 00147 return $this; 00148 }
read | ( | $ | csv = false , |
|
$ | delimiter = ',' , |
|||
$ | enclosure = '"' | |||
) |
Read up to 1K bytes from the file pointer Reading stops as soon as one of the following conditions is met: # length bytes have been read # EOF (end of file) is reached
Definition at line 170 of file Io.php.
00171 { 00172 if ($csv) { 00173 $content = $this->getIoAdapter()->streamReadCsv($delimiter, $enclosure); 00174 } 00175 else { 00176 $content = $this->getIoAdapter()->streamRead(1024); 00177 $this->_fileSize += strlen($content); 00178 } 00179 return $content; 00180 }
write | ( | $ | string | ) |
Write string
string | $string |
Definition at line 156 of file Io.php.
00157 { 00158 $this->_fileSize += strlen($string); 00159 return $this->getIoAdapter()->streamWrite($string); 00160 }