/** * @see File_Archive_Reader::next() */ function next() { if (!parent::next()) { return false; } $this->nbRead++; $this->filePos = 0; if ($this->nbRead > 1) { return false; } $dataFilename = $this->source->getDataFilename(); if ($dataFilename !== null) { $this->tmpName = null; $this->gzfile = gzopen($dataFilename, 'r'); } else { $this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far'); //Generate the tmp data $dest = new File_Archive_Writer_Files(); $dest->newFile($this->tmpName); $this->source->sendData($dest); $dest->close(); $this->gzfile = gzopen($this->tmpName, 'r'); } return true; }
/** * @see File_Archive_Reader::next() */ function next() { if (!parent::next()) { return false; } $this->nbRead++; if ($this->nbRead > 1) { return false; } $dataFilename = $this->source->getDataFilename(); if ($dataFilename !== null) { $this->tmpName = null; $this->bzfile = @bzopen($dataFilename, 'r'); if ($this->bzfile === false) { return PEAR::raiseError("bzopen failed to open {$dataFilename}"); } } else { $this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far'); //Generate the tmp data $dest = new File_Archive_Writer_Files(); $dest->newFile($this->tmpName); $this->source->sendData($dest); $dest->close(); $this->bzfile = bzopen($this->tmpName, 'r'); } return true; }
/** * @see File_Archive_Reader::next() */ function next() { $error = parent::next(); if (PEAR::isError($error)) { return $error; } if ($this->rarFile === null) { $dataFilename = $this->source->getDataFilename(); if ($dataFilename !== null) { $this->rarTmpName = null; $this->rarFile = rar_open($dataFilename); } else { $this->rarTmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far'); //Generate the tmp data $dest = new File_Archive_Writer_Files(); $dest->newFile($this->tmpName); $this->source->sendData($dest); $dest->close(); $this->rarFile = rar_open($this->tmpName); } if (!$this->rarFile) { return PEAR::raiseError("Unable to open rar file {$dataFilename}"); } if ($this->rarList === null) { $this->rarList = rar_list($this->rarFile); reset($this->rarList); } } if ($fileReader !== null) { $this->fileReader->close(); $this->fileReader = null; } $entryName = next($this->rarList); $this->source = null; if ($entryName === false) { return false; } $this->rarEntry = rar_entry_get($this->rarFile, $entryName); if (!$this->rarEntry) { return PEAR::raiseError("Error reading entry {$entryName}"); } return true; }