PHP
  Home arrow PHP arrow Page 5 - TAR File Management With PHP Archive_Tar
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

TAR File Management With PHP Archive_Tar
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 38
    2003-07-17


    Table of Contents:
  • TAR File Management With PHP Archive_Tar
  • Back To Basics
  • Zip Zap Zoom
  • Adding It All Up
  • Building An Index
  • In And Out
  • X-Ray Vision
  • ... And Packing Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    TAR File Management With PHP Archive_Tar - Building An Index
    ( Page 5 of 8 )

    You can obtain a list of all the files in a TAR archive with the Archive_Tar object's listContents() method, which returns an array of arrays containing detailed information on the contents of the archive. Each element of the returned array represents a file in the source archive, each element is itself structured as an associative array of key-value pairs containing details on the file name and path (key "filename"), size ("size"), owner and group ID ("uid" and "gid"), permissions ("fileperms"), last modification time ("mtime") and whether the entry is a file or directory ("type").

    Consider the following example, which demonstrates by using the
    listContents() method to obtain a list of all the files within a TAR file, together with their size and last modification times:


    <?php

    // include class
    require("Tar.php");

    // create tar file
    $tar = new Archive_Tar("data.tar");

    // read and print tar file contents
    if (($arr = $tar->listContent()) != 0)
    {
    foreach ($arr as $a)
    {
    echo $a['filename'] . ", " . $a['size'] . " bytes, last modified on " . date("Y-m-d", $a['mtime']) . "\r\n";
    }
    }

    ?>

    Here's an example of the output:


    scripts/pear.bat, 1570 bytes, last modified on 2002-04-09 scripts/pear.in, 6145 bytes, last modified on 2002-04-09 scripts/pearize.in, 4549 bytes, last modified on 2002-01-31 scripts/pearwin.php, 7507 bytes, last modified on 2002-02-20 scripts/php-config.in, 511 bytes, last modified on 2001-08-13 scripts/phpextdist, 620 bytes, last modified on 2001-01-10 scripts/phpize.in, 727 bytes, last modified on 2002-04-17 scripts/phptar.in, 5322 bytes, last modified on 2001-09-28 scripts/test2.php, 487 bytes, last modified on 2002-09-28



     
     
    >>> More PHP Articles          >>> More By The Disenchanted Developer, (c) Melonfire
     

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek