Add a file within the archive from a file

@param string $filename the path to the file we want to add
@param string $localname the local path to the file in the archive
@return true if the file has been successful added
164255
public function addFile($filename, $localname = null)
    {
        if (false === $this->openned) {
            return false;
        }
        if ((file_exists($this->filename) && !is_writable($this->filename))
            || !file_exists($filename)) {
            return false;
        }
        if (isset($localname)) {
            $localname = preg_replace("/(?:\.|\/)*(.*)/", "\\1", $localname);
            $localpath = dirname($localname);
            $tmpfilename = self::TMP_DIR . '/' . basename($localname);
        } else {
            $localname = basename($filename);
            $tmpfilename = self::TMP_DIR . '/' . $localname;
            $localpath = '';
        }
        if (file_exists($filename)) {
            copy($filename, $tmpfilename);
            $this->pclzip->delete(PCLZIP_OPT_BY_NAME, $localname);
            $this->pclzip->add($tmpfilename, PCLZIP_OPT_REMOVE_PATH, self::TMP_DIR, PCLZIP_OPT_ADD_PATH, $localpath);
            unlink($tmpfilename);
            return true;
        }
        return false;
    }
719853
public function addFile($file, $local = null)
    {
        if (null === $local) {
            $local = $file;
        }

        if (false === is_file($file)) {
            throw FileException::create(
                'The file "%s" does not exist or is not a file.',
                $file
            );
        }

        if (false === ($contents = @file_get_contents($file))) {
            throw FileException::lastError();
        }

        $this->addFromString($local, $contents);
    }
1289788
public function fileExists($fileName, $storageName = '')
    {
        //check whether file is set or not
        if ($fileName == '') {
            AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
            throw new Exception(Exception::MSG_NO_FILENAME);
        }

        //build URI
        $strURI = $this->strURIExist . $fileName;
        if ($storageName != '') {
            $strURI .= '?storage=' . $storageName;
        }
        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
        if (!$responseStream->FileExist->IsExist) {
            return FALSE;
        }
        return TRUE;
    }
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
786142
public function download($filename = 'backup.zip')
	{
		if ( ! preg_match('|.+?\.zip$|', $filename))
		{
			$filename .= '.zip';
		}

		$this->factory->helpers->load('download');
		$get_zip = $this->get_zip();
		$zip_content =& $get_zip;

		force_download($filename, $zip_content);
	}
515853
public void addFile(String filename, String filePath) {
        int pathIndex = filePathList.indexOf(filePath);
        if (pathIndex == -1) {
            fileNameList.add(filename);
            filePathList.add(filePath);
        }
    }
564951
public function
	ShouldWriteToDisk($filename,$source) {
	/*//
	//*/

		if(!file_exists($filename))
		return true;

		$old = md5(static::StripScriptHeader(file_get_contents($filename)));
		$new = md5(static::StripScriptHeader($source));

		if($old !== $new) return true;
		else return false;
	}
651660
public function setFilename($filename)
    {
        $filename = $this->filterFilename($filename);

        // Check existing folder path
        $folder = '';
        $parent = $this->Parent();
        if ($parent && $parent->exists()) {
            $folder = $parent->getFilename();
        }

        // Detect change in foldername
        $newFolder = ltrim(dirname(trim($filename, '/')), '.');
        if ($folder !== $newFolder) {
            if (!$newFolder) {
                $this->ParentID = 0;
            } else {
                $parent = Folder::find_or_make($newFolder);
                $this->ParentID = $parent->ID;
            }
        }

        // Update base name
        $this->Name = basename($filename);
        return $this;
    }
605837
public function open($filename)
    {
        $this->filename = $filename;
        return $this->zipArchive->open($filename, ZIPARCHIVE::CREATE);
    }
192437
public function saveToFile($FileName = null)
    {
        if (! is_null($FileName)) {
            $this->FileName = $FileName;
        }

        if (($this->_openSHPFile(true)) && ($this->_openSHXFile(true)) && ($this->_createDBFFile())) {
            $this->_saveHeaders();
            $this->_saveRecords();
            $this->_closeSHPFile();
            $this->_closeSHXFile();
            $this->_closeDBFFile();
        } else {
            return false;
        }
    }
31550
protected function upload($local_file)
    {
        if (!is_file($local_file)) {
            throw new WebDriverException('You may only upload files: ' . $local_file);
        }

        // Create a temporary file in the system temp directory.
        $temp_zip = tempnam(sys_get_temp_dir(), 'WebDriverZip');
        $zip = new ZipArchive();
        if ($zip->open($temp_zip, ZipArchive::CREATE) !== true) {
            return false;
        }
        $info = pathinfo($local_file);
        $file_name = $info['basename'];
        $zip->addFile($local_file, $file_name);
        $zip->close();
        $params = [
            'file' => base64_encode(file_get_contents($temp_zip)),
        ];
        $remote_path = $this->executor->execute(
            DriverCommand::UPLOAD_FILE,
            $params
        );
        unlink($temp_zip);

        return $remote_path;
    }
172675
public function createFileHeader($localname, $filename)
    {
        return (object) array(
            'filename' => $filename,
            'stored_filename' => $localname,
            'size' => filesize($filename),
            'compressed_size' => ceil(filesize($filename)
                / self::AVERAGE_ZIP_COMPRESSION_RATIO),
            'mtime' => filemtime($filename),
            'comment' => null,
            'folder' => is_dir($filename),
            'status' => 'ok',
        );
    }
134542
public static function copy(string $filename, string $path): bool
    {
        return @copy($filename, $path . '/' . self::basename($filename));
    }
311900
public function saveAs($filename) {
    if (!$this->_isCreated && !$this->createPdf()) {
      return FALSE;
    }
    if (!$this->_tmpPdfFile->saveAs($filename)) {
      $this->_error = "Could not save PDF as '$filename'";
      return FALSE;
    }
    return TRUE;
  }
655548
public static function addAttachmentFromFile($object, $filename)
    {
        return self::addAttachment($object, basename($filename),
                file_get_contents($filename), mime_content_type($filename));
    }
705793
public static function loadFile($fileName)
  {
    if (!preg_match('/\.ini$/i', $fileName)) {
      $fileName .= '.ini';
    }
    if (!static::isFileLoaded($fileName)) {
      self::$files[] = $fileName;
      return static::loadFileInMemory($fileName);
    }
    return false;
  }
118239
public function append($filename, $content)
    {
        if ($this->exists($filename) && $this->isFile($filename)) {
            return file_put_contents($filename, $content, FILE_APPEND);
        }

        throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
    }