Mage_Dataflow_Model_Batch_Io Class Reference

List of all members.

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


Detailed Description

Definition at line 35 of file Io.php.


Member Function Documentation

clear (  ) 

Definition at line 192 of file Io.php.

00193     {
00194         return $this->getIoAdapter()->rm($this->getFile(true));
00195     }

close (  ) 

Close file

Returns:
bool

Definition at line 187 of file Io.php.

00188     {
00189         return $this->getIoAdapter()->streamClose();
00190     }

getFile ( withPath = false  ) 

Retrieve tmp filename

Returns:
string

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 (  ) 

Get writed file size

Returns:
unknown

Definition at line 202 of file Io.php.

00203     {
00204         return $this->_fileSize;
00205     }

getIoAdapter (  ) 

Retrieve Io File Adapter

Returns:
Varien_Io_File

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

Returns:
string

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)

Parameters:
Mage_Dataflow_Model_Batch $object
Returns:
Mage_Dataflow_Model_Batch_Io

Definition at line 81 of file Io.php.

00082     {
00083         $this->_batchModel = $object;
00084         return $this;
00085     }

open ( write = true  ) 

Open file in stream mode

Returns:
Mage_Dataflow_Model_Batch_Io

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

Returns:
string|array

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

Parameters:
string $string
Returns:
bool

Definition at line 156 of file Io.php.

00157     {
00158         $this->_fileSize += strlen($string);
00159         return $this->getIoAdapter()->streamWrite($string);
00160     }


Member Data Documentation

$_batchModel [protected]

Definition at line 45 of file Io.php.

$_filename [protected]

Definition at line 59 of file Io.php.

$_fileSize = 0 [protected]

Definition at line 73 of file Io.php.

$_ioFile [protected]

Definition at line 66 of file Io.php.

$_path [protected]

Definition at line 52 of file Io.php.

const TMP_DIR = '/var/tmp/'

Definition at line 37 of file Io.php.

const TMP_NAME = 'batch_%d.tmp'

Definition at line 38 of file Io.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:04 2009 for Magento by  doxygen 1.5.8