Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36948 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31879 invoked from network); 11 Apr 2008 13:55:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2008 13:55:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:51218] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/79-17995-2DD6FF74 for ; Fri, 11 Apr 2008 09:55:32 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 8B18AC100CD for ; Fri, 11 Apr 2008 06:55:29 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-4-101.neb.res.rr.com [76.84.4.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 3A667C100C6 for ; Fri, 11 Apr 2008 06:55:29 -0700 (MST) Message-ID: <47FF6DDD.8080507@chiaraquartet.net> Date: Fri, 11 Apr 2008 08:55:41 -0500 User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: internals Mailing List X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: phar API update From: greg@chiaraquartet.net (Gregory Beaver) Hi, A quick update on Phar's API for those who are keeping score: 1) Phar->isWritable() now works properly and does what Liz was hoping: tells you whether you can actually modify the phar archive by looking at the archive's file perms as well as phar.readonly 2) PharFileInfo->getContent() added to retrieve file contents like $phar['a.txt']->getContent() 3) addFile/addFromString/addEmptyDir added to match ext/zip API 4) fixed compression API. Here are the new methods: bool Phar->isCompressed([int compression]) // takes Phar::GZ, Phar::BZ2 or no parameter to check for any whole-archive compression Phar|PharData Phar->compress(int compression[, string ext]) // takes Phar::GZ/Phar::BZ2 and optional file extension to override default renaming Phar|PharData Phar->decompress([, string ext]) // takes optional file extension to override default renaming bool Phar->compressFiles(int compression) // takes Phar::GZ/Phar::BZ2 and compressed all files within the archive bool Phar->decompressFiles() // decompress all files within the archive Phar Phar->convertToExecutable([int format[, int compression[, string ext]]]) PharData Phar->convertToData([int format[, int compression[, string ext]]]) // takes Phar::TAR, Phar::ZIP, or Phar::PHAR as format // takes Phar::GZ, Phar::BZ2 as compression // optional file extension to override default renaming PharFileInfo->isCompressed([int compression]) // takes Phar::GZ, Phar::BZ2 or no parameter to check for any compression of file within the archive PharFileInfo->compress(int compression) // Phar::GZ/Phar::BZ2 PharFileInfo->decompress() Here's code example of the new API: convertToData(Phar::TAR); // creates blah.tar $tgz = $tar->compress(Phar::GZ); // creates blah.tar.gz $phargz = $tar->convertToExecutable(Phar::PHAR, Phar::GZ, '.gz.phar'); // creates blah.gz.phar (default would be blah.phar.gz) var_dump($tgz->isCompressed(), $tgz->isCompressed(Phar::GZ), $tgz->isCompressed(Phar::BZ2)); // true, true, false $phar['a.txt'] = 'hi'; echo $phar['a.txt']->getContent(); // "hi" $phar->compressFiles(Phar::GZ); // internal files compressed with zlib compression var_dump($phar['a.txt']->isCompressed(), $phar['a.txt']->isCompressed(Phar::GZ), $phar['a.txt']->isCompressed(Phar::BZ2)); // true, true, false $phar['a.txt']->decompress(); // now this specific file is not compressed within the archive $phar->decompressFiles(); // internal files decompressed $phar['a.txt']->compress(Phar::BZ2); // now this specific file is compressed with bzip2 compression $tar2 = $tgz->decompress('.2.tar'); // creates blah.2.tar $phartar2 = $tar2->convertToExecutable(); // create blah.2.phar.tar ?> Thanks, Greg