Author: Raymond Bosman
Date: 2006-01-26 11:53:23 +0100 (Thu, 26 Jan 2006)
New Revision: 2039
Log:
- Changed the ezcArchive::getInstance() method to ezcArchive::open(). This
change is made because getInstance() gives the impression that ezcArchive
is a singleton.
Modified:
packages/Archive/trunk/ChangeLog
packages/Archive/trunk/docs/tutorial_extract.php
packages/Archive/trunk/docs/tutorial_iterator.php
packages/Archive/trunk/docs/tutorial_replacing.php
packages/Archive/trunk/src/archive.php
packages/Archive/trunk/tests/archive_test.php
Modified: packages/Archive/trunk/ChangeLog
===================================================================
--- packages/Archive/trunk/ChangeLog 2006-01-26 09:44:37 UTC (rev 2038)
+++ packages/Archive/trunk/ChangeLog 2006-01-26 10:53:23 UTC (rev 2039)
@@ -1,3 +1,10 @@
+1.0 - [RELEASEDATE]
+
+- Changed the ezcArchive::getInstance() method to ezcArchive::open(). This
+ change is made because getInstance() gives the impression that ezcArchive
+ is a singleton.
+
+
1.0rc1 - Monday 16 January 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modified: packages/Archive/trunk/docs/tutorial_extract.php
===================================================================
--- packages/Archive/trunk/docs/tutorial_extract.php 2006-01-26 09:44:37 UTC
(rev 2038)
+++ packages/Archive/trunk/docs/tutorial_extract.php 2006-01-26 10:53:23 UTC
(rev 2039)
@@ -4,7 +4,7 @@
date_default_timezone_set( "UTC" );
// Open the gzipped TAR archive.
-$archive = ezcArchive::getInstance( "compress.zlib:///tmp/my_archive.tar.gz" );
+$archive = ezcArchive::open( "compress.zlib:///tmp/my_archive.tar.gz" );
while( $archive->valid() )
{
Modified: packages/Archive/trunk/docs/tutorial_iterator.php
===================================================================
--- packages/Archive/trunk/docs/tutorial_iterator.php 2006-01-26 09:44:37 UTC
(rev 2038)
+++ packages/Archive/trunk/docs/tutorial_iterator.php 2006-01-26 10:53:23 UTC
(rev 2039)
@@ -3,7 +3,7 @@
include( "tutorial_autoload.php" );
date_default_timezone_set( "UTC" );
-$archive = ezcArchive::getInstance( "compress.zlib:///tmp/my_archive.tar.gz" );
+$archive = ezcArchive::open( "compress.zlib:///tmp/my_archive.tar.gz" );
// The foreach method calls internally the iterator methods.
foreach( $archive as $entry )
Modified: packages/Archive/trunk/docs/tutorial_replacing.php
===================================================================
--- packages/Archive/trunk/docs/tutorial_replacing.php 2006-01-26 09:44:37 UTC
(rev 2038)
+++ packages/Archive/trunk/docs/tutorial_replacing.php 2006-01-26 10:53:23 UTC
(rev 2039)
@@ -3,7 +3,7 @@
include( "tutorial_autoload.php" );
date_default_timezone_set( "UTC" );
-$archive = ezcArchive::getInstance( "/tmp/my_archive.zip" );
+$archive = ezcArchive::open( "/tmp/my_archive.zip" );
$archive->truncate();
$filesToAppend[] = "/tmp/file1.txt";
Modified: packages/Archive/trunk/src/archive.php
===================================================================
--- packages/Archive/trunk/src/archive.php 2006-01-26 09:44:37 UTC (rev
2038)
+++ packages/Archive/trunk/src/archive.php 2006-01-26 10:53:23 UTC (rev
2039)
@@ -16,10 +16,10 @@
* archive itself can be compressed with GZip or BZip2 and will be handled
* transparently.
*
- * The [EMAIL PROTECTED] getInstance()} method creates a new archive instance.
For
+ * The [EMAIL PROTECTED] open()} method creates a new archive instance. For
* existing archives, ezcArchive determines the correct archive format by the
* mime-type and returns an instance of a subclass handling this format.
- * New archives should force a format type via a parameter in the getInstance()
+ * New archives should force a format type via a parameter in the open()
* method.
*
* The instance of an ezcArchive class is also an iterator, which
@@ -36,8 +36,8 @@
* The following example will open an existing tar.gz file and will append each
* file to a zip archive:
* <code>
- * $tar = ezcArchive::getInstance( "/tmp/archive.tar.gz" );
- * $newZip = ezcArchive::getInstance( "/tmp/new_archive.zip", ezcArchive::ZIP
);
+ * $tar = ezcArchive::open( "/tmp/archive.tar.gz" );
+ * $newZip = ezcArchive::open( "/tmp/new_archive.zip", ezcArchive::ZIP );
*
* foreach( $tar as $entry )
* {
@@ -139,7 +139,7 @@
protected $file = null;
/**
- * Use the [EMAIL PROTECTED] getInstance()} method to get an instance of
this class.
+ * Use the [EMAIL PROTECTED] open()} method to get an instance of this
class.
*/
private function __construct()
{
@@ -168,7 +168,7 @@
*
* @return ezcArchive
*/
- public static function getInstance( $archiveName, $forceType = null)
+ public static function open( $archiveName, $forceType = null)
{
if ( !ezcArchiveFile::fileExists( $archiveName ) && $forceType ===
null )
{
@@ -269,7 +269,7 @@
/**
* Returns an instance of the archive with the given type.
*
- * @see getInstance() Similar to getInstance(), but the type is required.
+ * Similar to [EMAIL PROTECTED] open()}, but the type is required.
*
* @param string $archiveName The path of the archive.
* @param int $type Open the archive with the $forceType
Modified: packages/Archive/trunk/tests/archive_test.php
===================================================================
--- packages/Archive/trunk/tests/archive_test.php 2006-01-26 09:44:37 UTC
(rev 2038)
+++ packages/Archive/trunk/tests/archive_test.php 2006-01-26 10:53:23 UTC
(rev 2039)
@@ -18,7 +18,7 @@
public function testRecognizePaxTar()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
$this->assertNotNull( $archive );
$this->assertEquals( ezcArchive::TAR_PAX, $archive->getAlgorithm() );
@@ -28,7 +28,7 @@
public function testRecognizeGnuTar()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_gnu_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_gnu_2_textfiles.tar" );
$this->assertNotNull( $archive );
$this->assertEquals( ezcArchive::TAR_GNU, $archive->getAlgorithm() );
@@ -38,7 +38,7 @@
public function testRecognizeUstar()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_ustar_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_ustar_2_textfiles.tar" );
$this->assertNotNull( $archive );
$this->assertEquals( ezcArchive::TAR_USTAR, $archive->getAlgorithm() );
@@ -48,7 +48,7 @@
public function testRecognizeV7Tar()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_v7_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_v7_2_textfiles.tar" );
$this->assertNotNull( $archive );
$this->assertEquals( ezcArchive::TAR_V7, $archive->getAlgorithm() );
@@ -58,7 +58,7 @@
public function testRecognizeZip()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/infozip_2_textfiles.zip" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/infozip_2_textfiles.zip" );
$this->assertNotNull( $archive );
$this->assertEquals( ezcArchive::ZIP, $archive->getAlgorithm() );
@@ -70,7 +70,7 @@
{
// Just choose one type. The specific algorithms are already tested.
$dir = $this->getTempDir();
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
$archive->extract( $dir );
clearstatcache();
@@ -86,7 +86,7 @@
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
exec( "gzip $dir/mytar.tar" );
- $archive = ezcArchive::getInstance( "$dir/mytar.tar.gz" );
+ $archive = ezcArchive::open( "$dir/mytar.tar.gz" );
$archive->extract( $dir );
clearstatcache();
@@ -102,7 +102,7 @@
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
exec( "gzip $dir/mytar.tar" );
- $archive = ezcArchive::getInstance(
"compress.zlib://$dir/mytar.tar.gz" );
+ $archive = ezcArchive::open( "compress.zlib://$dir/mytar.tar.gz" );
$archive->extract( $dir );
$archive->rewind();
@@ -132,7 +132,7 @@
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
exec( "bzip2 $dir/mytar.tar" );
- $archive = ezcArchive::getInstance(
"compress.bzip2://$dir/mytar.tar.bz2" );
+ $archive = ezcArchive::open( "compress.bzip2://$dir/mytar.tar.bz2" );
//echo ( $archive );
$archive->extract( $dir );
@@ -163,7 +163,7 @@
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
exec( "bzip2 $dir/mytar.tar" );
- $archive = ezcArchive::getInstance( "$dir/mytar.tar.bz2" );
+ $archive = ezcArchive::open( "$dir/mytar.tar.bz2" );
$archive->extract( $dir );
$archive->rewind();
@@ -193,7 +193,7 @@
exec( "gzip $dir/mytar.tar" );
exec( "bzip2 $dir/mytar.tar.gz" );
- $archive = ezcArchive::getInstance( "$dir/mytar.tar.gz.bz2" );
+ $archive = ezcArchive::open( "$dir/mytar.tar.gz.bz2" );
$archive->extract( $dir );
@@ -210,7 +210,7 @@
try
{
- $archive = ezcArchive::getInstance( "$dir/mytar.tar",
ezcArchive::TAR_V7 );
+ $archive = ezcArchive::open( "$dir/mytar.tar", ezcArchive::TAR_V7
);
$entry = $archive->current();
$this->fail("This is not an Tar, so throw an exception");
}
@@ -225,7 +225,7 @@
try
{
- $archive = ezcArchive::getInstance(
"compress.bzip2://$dir/mytar.tar.bz2" );
+ $archive = ezcArchive::open( "compress.bzip2://$dir/mytar.tar.bz2"
);
file_put_contents( "$dir/file3.txt", "Hahaha");
$archive->appendToCurrent( "$dir/file3.txt", $dir);
@@ -241,7 +241,7 @@
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
exec( "bzip2 $dir/mytar.tar" );
- $archive = ezcArchive::getInstance( "$dir/mytar.tar.bz2" );
+ $archive = ezcArchive::open( "$dir/mytar.tar.bz2" );
try
{
@@ -266,7 +266,7 @@
rename( "$dir/mytar.tar.gz", "$dir/mytar.tar.a");
exec( "gzip $dir/mytar.tar.a" );
- $archive = ezcArchive::getInstance( "$dir/mytar.tar.a.gz" );
+ $archive = ezcArchive::open( "$dir/mytar.tar.a.gz" );
$archive->extract( $dir );
clearstatcache();
@@ -285,7 +285,7 @@
try
{
// File size too small.
- $archive = ezcArchive::getInstance( "$dir/myzip.zip",
ezcArchive::TAR_V7 );
+ $archive = ezcArchive::open( "$dir/myzip.zip", ezcArchive::TAR_V7
);
$archive->extract( $dir );
$this->fail( "Exception expected since we cannot extract a Zip
archive with the Tar handler. ");
}
@@ -303,7 +303,7 @@
try
{
// CRC is incorrect.
- $archive = ezcArchive::getInstance( "$dir/myzip.zip",
ezcArchive::TAR_V7 );
+ $archive = ezcArchive::open( "$dir/myzip.zip", ezcArchive::TAR_V7
);
$archive->extract( $dir );
$this->fail( "Exception expected since we cannot extract a Zip
archive with the Tar handler. ");
@@ -317,7 +317,7 @@
public function testCreateNewArchive()
{
$dir = $this->getTempDir();
- $archive = ezcArchive::getInstance( "$dir/myzip.zip", ezcArchive::ZIP
);
+ $archive = ezcArchive::open( "$dir/myzip.zip", ezcArchive::ZIP );
file_put_contents( "$dir/bla.txt", "Hello world");
file_put_contents( "$dir/bla2.txt", "Hello world2");
$archive->append("$dir/bla.txt", "$dir");
@@ -333,7 +333,7 @@
$dir = $this->getTempDir();
try
{
- $archive = ezcArchive::getInstance( "$dir/myzip.zip" );
+ $archive = ezcArchive::open( "$dir/myzip.zip" );
$this->fail( "Exception expected, because the type is missing");
}
catch ( ezcArchiveException $e )
@@ -345,7 +345,7 @@
public function testCreateNewGzippedTar()
{
$dir = $this->getTempDir();
- $archive = ezcArchive::getInstance( "compress.zlib://$dir/my.tar.gz",
ezcArchive::TAR );
+ $archive = ezcArchive::open( "compress.zlib://$dir/my.tar.gz",
ezcArchive::TAR );
file_put_contents( "$dir/bla.txt", "Hello world");
file_put_contents( "$dir/bla2.txt", "Hello world2");
@@ -359,7 +359,7 @@
// Second check: Reread the archive.. and read it.
- $archive = ezcArchive::getInstance( "$dir/my.tar.gz" );
+ $archive = ezcArchive::open( "$dir/my.tar.gz" );
$this->assertEquals( "bla.txt", $archive->current()->getPath() );
$this->assertEquals( "bla2.txt", $archive->next()->getPath() );
}
@@ -370,7 +370,7 @@
$dir = $this->getTempDir();
copy( dirname( __FILE__ ) . "/data/winzip_1_textfile.zip",
"$dir/myzip.zip");
- $archive = ezcArchive::getInstance( "$dir/myzip.zip" );
+ $archive = ezcArchive::open( "$dir/myzip.zip" );
$archive->extract( $dir );
$this->assertEquals( "Hello world 2!!", file_get_contents(
"$dir/ray2.txt" ) );
@@ -381,7 +381,7 @@
$dir = $this->getTempDir();
copy( dirname( __FILE__ ) . "/data/winzip_1_textfile.zip",
"$dir/myzip.zip");
- $archive = ezcArchive::getInstance( "$dir/myzip.zip" );
+ $archive = ezcArchive::open( "$dir/myzip.zip" );
file_put_contents( "$dir/myfile.txt", "Hi");
$archive->append( "$dir/myfile.txt", $dir );
@@ -391,7 +391,7 @@
unset( $archive );
- $archive = ezcArchive::getInstance( "$dir/myzip.zip" );
+ $archive = ezcArchive::open( "$dir/myzip.zip" );
$this->assertEquals( "ray2.txt", $archive->current()->getPath() );
$this->assertEquals( "myfile.txt", $archive->next()->getPath() );
@@ -399,7 +399,7 @@
public function testListing()
{
- $archive = ezcArchive::getInstance( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
+ $archive = ezcArchive::open( dirname( __FILE__ ) .
"/data/tar_pax_2_textfiles.tar" );
$list = $archive->getListing();
$this->assertEquals( "file1.txt", substr( $list[0], -9 ) );
@@ -410,7 +410,7 @@
{
$dir = $this->getTempDir();
copy( dirname( __FILE__ ) . "/data/tar_ustar_2_textfiles.tar",
"$dir/mytar.tar");
- $archive = ezcArchive::getInstance( "$dir/mytar.tar" );
+ $archive = ezcArchive::open( "$dir/mytar.tar" );
file_put_contents( "$dir/haha.txt", "Hahahah");
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components