cvs: pear /PHP_Archive/Archive Creator.php
| From: | Greg Beaver | Date: | Mon, 11 Apr 2005 05:23:17 +0000 |
| Subject: | cvs: pear /PHP_Archive/Archive Creator.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-31092@lists.php.net to get a copy of this message | ||
cellog Mon Apr 11 01:23:17 2005 EDT
Modified files:
/pear/PHP_Archive/Archive Creator.php
Log:
make addString() function in order to add strings as files
http://cvs.php.net/diff.php/pear/PHP_Archive/Archive/Creator.php?r1=1.5&r2=1.6&ty=u
Index: pear/PHP_Archive/Archive/Creator.php
diff -u pear/PHP_Archive/Archive/Creator.php:1.5 pear/PHP_Archive/Archive/Creator.php:1.6
--- pear/PHP_Archive/Archive/Creator.php:1.5 Mon Apr 11 01:11:49 2005
+++ pear/PHP_Archive/Archive/Creator.php Mon Apr 11 01:23:16 2005
@@ -31,7 +31,7 @@
* @copyright Copyright © David Shafik and Synaptic Media 2004. All rights reserved.
* @author Davey Shafik <davey@synapticmedia.net>
* @link http://www.synapticmedia.net Synaptic Media
- * @version $Id: Creator.php,v 1.5 2005/04/11 05:11:49 cellog Exp $
+ * @version $Id: Creator.php,v 1.6 2005/04/11 05:23:16 cellog Exp $
* @package PHP_Archive
* @category PHP
* @example c:\web\php-cvs\pear\PHP_Archive\docs\examples\PHP_Archive_Creator_Example_1.php Example
PHP_Archive_Creator usage
@@ -173,7 +173,6 @@
function addFile($file, $save_path)
{
- $this->modified = true;
$file_contents = file_get_contents($file);
if ($this->compress) {
$file_contents = '1' . base64_encode(
@@ -188,6 +187,28 @@
}
/**
+ * Add a string to the PHP Archive as a file
+ *
+ * @param string $file_contents Contents of the File to add
+ * @param string $save_path The save location of the file in the archive
+ * @return boolean
+ */
+
+ function addString($file_contents, $save_path)
+ {
+ if ($this->compress) {
+ $file_contents = '1' . base64_encode(
+ pack("C1C1C1C1VC1C1", 0x1f, 0x8b, 8, 0, time(), 2, 0xFF) .
+ gzdeflate($file_contents, 9) .
+ pack("VV",crc32($file_contents),strlen($file_contents)));
+ } else {
+ $file_contents = '0' . $file_contents;
+ }
+ clearstatcache(); // a newly created archive could be erased if this is not performed
+ return $this->tar->addString($save_path, $file_contents);
+ }
+
+ /**
* Tell whether to ignore a file or a directory
* allows * and ? wildcards
*