/** * The most basic file transaction: add a single entry (file or directory) to * the archive. * * @param bool $isVirtual If true, the next parameter contains file data instead of a file name * @param string $sourceNameOrData Absolute file name to read data from or the file data itself is $isVirtual is true * @param string $targetName The (relative) file name under which to store the file in the archive * @return True on success, false otherwise * @since 1.2.1 * @access protected * @abstract */ function _addFile($isVirtual, &$sourceNameOrData, $targetName) { // Are we connected to a server? if (!is_resource($this->_ftphandle)) { if (!$this->_connectFTP()) { return false; } } // See if it's a directory $isDir = $isVirtual ? false : is_dir($sourceNameOrData); if ($isDir) { // Just try to create the remote directory return $this->_makeDirectory($targetName); } else { // We have a file we need to upload if ($isVirtual) { // Create a temporary file, upload, rename it $tempFileName = JoomlapackCUBETempfiles::createRegisterTempFile(); if (function_exists('file_put_contents')) { if (@file_put_contents($tempFileName, $sourceNameOrData) === false) { $this->setError('Could not upload virtual file ' . $targetName); return false; } $res = $this->_upload($tempFileName, $targetName); JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($tempFileName, true); return $res; } } else { // Upload a file return $this->_upload($sourceNameOrData, $targetName); } } }