cvs: peardoc /en/packages/file archive-tar.xml
| From: | Vincent Blavet | Date: | Sat, 16 Feb 2002 14:16:36 +0000 |
| Subject: | cvs: peardoc /en/packages/file archive-tar.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2450@lists.php.net to get a copy of this message | ||
vblavet Sat Feb 16 09:16:36 2002 EDT
Modified files:
/peardoc/en/packages/file archive-tar.xml
Log:
* Correct doc
* Add Examples
Index: peardoc/en/packages/file/archive-tar.xml diff -u peardoc/en/packages/file/archive-tar.xml:1.4 peardoc/en/packages/file/archive-tar.xml:1.5 --- peardoc/en/packages/file/archive-tar.xml:1.4 Sun Feb 10 18:00:44 2002 +++ peardoc/en/packages/file/archive-tar.xml Sat Feb 16 09:16:36 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="packages.file.archive-tar"> <refnamediv> <refname>Archive_Tar</refname> @@ -24,12 +24,12 @@ <itemizedlist> <listitem> <para> - <parameter>$tarname</parameter> - the name of the tar archive to create + <parameter>$tarname</parameter> - the name of the tar archive to work with </para> </listitem> <listitem> <para> - <parameter>$compress</parameter> - if true, the archive will be + <parameter>$compress</parameter> - if true, indicates that the archive is gezip(ped). Default is <parameter>false</parameter>. </para> </listitem> @@ -48,9 +48,9 @@ <para> This method creates the archive file and add the listed files or directories. - If a file with the same name exist and is writable, it is replaced - by the new tar. - The method return false and a PEAR error text. + If a file with the same tarname exist and is writable, it is replaced + by the new tar (it is not an 'add' but a 'create'). If a file exists and is write protected or is a folder, + the method return false and a PEAR error text. The list can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a @@ -75,11 +75,43 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success, <parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + + <example> + <title>create()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling +$v_list[0]="file.txt"; +$v_list[1]="data/"; // Optional '/' at the end +$v_list[2]="file.log"; +$tar_object->create($v_list); + ]]> + </programlisting> + </example> + <para> + In this example a not compressed Tar archive is created. The files 'file.txt' and 'file.log' are + added, all the directory 'data' is added. + </para> + <example> + <title>create()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling +$tar_object->create("file.txt data/ file.log"); + ]]> + </programlisting> + </example> + <para> + In this example a compressed Tar archive is created. The same files and directory are added, + but without using an array. + </para> </refsect1> <refsect1 id="packages.file.archive-tar.add"> @@ -91,11 +123,10 @@ </funcprototype> </funcsynopsis> <para> - This method add the files / directories that are listed in $p_filelist in - the archive. If the archive does not exist it is created. + This method add the files / directories that are listed in $filelist in + the existing archive. If the archive does not exist it is created. The files and directories listed are only added at the end of the archive, even if a file with the same name is already archived. - The method return false and a PEAR error text. </para> <para> Parameter @@ -114,11 +145,23 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success, <parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + <example> + <title>add()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; // Optional '/' at the end +$v_list[2]="log/file.log"; +$tar_object->add($v_list); + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extract"> @@ -130,7 +173,29 @@ </funcprototype> </funcsynopsis> <para> - Extracts the files to the archive into the given path. + Extracts the files from the archive into the given path. + </para> + <para> + While extracting a file : If the file already exists it is replaced + without looking for last modification date. + If the file already exists and is write + protected, the extraction is aborted. + If a directory with the same name already + exists, the extraction is aborted. + </para> + <para> + While extracting a directory, if a file with the same name already + exists, the extraction is aborted. + While extracting a file/directory if the destination directory exist + and is write protected, or does not exist but can not be created, + the extraction is aborted. + If after extraction an extracted file does not show the correct + stored file size, the extraction is aborted. + </para> + <para> + When the extraction is aborted, a PEAR error text is set and false + is returned. However the result can be a partial extraction that may + need to be manually cleaned. </para> <para> Parameter @@ -148,11 +213,20 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success,<parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + <example> + <title>extract()</title> + <programlisting role="php"> + <![CDATA[ +$tar = new Archive_Tar('archive.tgz', true); +$result = $tar->extract('destination_folder'); + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.listcontent"> @@ -164,18 +238,70 @@ </funcprototype> </funcsynopsis> <para> - Lists the files of the archive + Lists the files and the directories of the archive. + </para> + <para> + The result is an array, each entry representing a file or folder. + The array is not sorted, so the index shows the position of the file/dir in the + archive. + </para> + <para> + Each entry has the following informations : + <itemizedlist> + <listitem> + <para> + $file[filename] : Name and path of the file/dir. + </para> + <para> + $file[mode] : File permissions (result of fileperms()) + </para> + <para> + $file[uid] : user id + </para> + <para> + $file[gid] : group id + </para> + <para> + $file[size] : filesize + </para> + <para> + $file[mtime] : Last modification time (result of filemtime()) + </para> + <para> + $file[typeflag] : "" for file, "5" for directory + </para> + </listitem> + </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> - <parameter>array</parameter> - a list of the files + <parameter>array</parameter> - a list of the files/directories properties </para> </listitem> </itemizedlist> </para> + <example> + <title>listContent()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +if (($v_list = $tar_object->listContent()) != 0) + for ($i=0; $i<sizeof($v_list); $i++) { + echo "Filename :'".$v_list[$i][filename]."'<br>"; + echo " .size :'".$v_list[$i][size]."'<br>"; + echo " .mtime :'".$v_list[$i][mtime]."' (". + date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; + echo " .mode :'".$v_list[$i][mode]."'<br>"; + echo " .uid :'".$v_list[$i][uid]."'<br>"; + echo " .gid :'".$v_list[$i][gid]."'<br>"; + echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; + } + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.addmodify"> @@ -193,7 +319,9 @@ <para> This method add the files or directories listed in <parameter> filelist</parameter> at the end of the existing archive. - If the archive does not yet exists it is created. + </para> + <para> + If the archive does not exists it is created. If a file or directory is already in the archive it will only be added at the end of the archive. There is no update of the existing archived file or directory. However while extracting the archive, the last file will @@ -204,16 +332,16 @@ ignored. </para> <para> - The path indicated in <parameter>$remove_dir</parameter> will be removed from + The path indicated in <parameter>remove_dir</parameter> will be removed from the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') - The path indicated in <parameter>$add_dir</parameter> will be added at the + The path indicated in <parameter>add_dir</parameter> will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive - for extraction in a different path than the origin files are. + for extraction in a different path than the original path. </para> <para> Parameter @@ -241,7 +369,7 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success,<parameter>false</parameter> on error + success, <parameter>false</parameter> on error </para> </listitem> </itemizedlist> @@ -250,9 +378,35 @@ <title>addModify()</title> <programlisting role="php"> <![CDATA[ - $tar = new Archive_Tar('archive.tgz', true); - $result = $tar->addModify('data/file.txt', 'user', 'data'); - // File will be added in the archive like : 'user/file.txt' +$tar_object = new Archive_Tar("tarname.tar"); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->addModify($v_list, "install"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/file.log + ]]> + </programlisting> + </example> + <example> + <title>addModify()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->addModify($v_list, "install", "dev"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/log/file.log ]]> </programlisting> </example> @@ -272,11 +426,14 @@ </funcsynopsis> <para> This method creates the archive file and add the listed files or - directories. If the file already exists and is writable, it is replaced + directories. + </para> + <para> + If the file already exists and is writable, it is replaced by the new tar. It is a create and not an add. If the file exists and is read-only or is a directory it is not replaced. The path add/remove ability enables the user to prepare an archive - for extraction in a different path than the origin files are. + for extraction in a different path than the origin files are (see Archive_Tar::addModify()). </para> <para> Parameter @@ -309,6 +466,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>createModify()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->createModify($v_list, "install", "dev"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/log/file.log + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extractmodify"> @@ -323,24 +499,31 @@ </funcsynopsis> <para> This method extract all the content of the archive in the directory - indicated by <parameter>$path</parameter>. When relevant the memorized + indicated by <parameter>path</parameter>. When relevant the memorized path of the files or directories can be modified by removing the - <parameter>$remove_path</parameter> path at the beginning of the - file or directory path. While extracting a file, if the directory path - does not exists it is created. While extracting a file, if the file already - exists it is replaced without looking for last modification date. - while extracting a file, if the file already exists and is write + <parameter>remove_path</parameter> path at the beginning of the + file or directory path. + </para> + <para> + While extracting a file : If the file already exists it is replaced + without looking for last modification date. + If the file already exists and is write protected, the extraction is aborted. - while extracting a file, if a directory with the same name already + If a directory with the same name already exists, the extraction is aborted. - while extracting a directory, if a file with the same name already + </para> + <para> + While extracting a directory, if a file with the same name already exists, the extraction is aborted. - while extracting a file/directory if the destination directory exist + While extracting a file/directory if the destination directory exist and is write protected, or does not exist but can not be created, the extraction is aborted. If after extraction an extracted file does not show the correct stored file size, the extraction is aborted. - In such cases, the result can be a partial extraction that may + </para> + <para> + When the extraction is aborted, a PEAR error text is set and false + is returned. However the result can be a partial extraction that may need to be manually cleaned. </para> <para> @@ -369,6 +552,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>extractModify()</title> + <programlisting role="php"> + <![CDATA[ +// tarname.tar with files : +// dev/data/file.txt +// dev/data/log.txt +// readme.txt + +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->extractModify("install", "dev"); + +// Files will be extracted there : +// install/data/file.txt +// install/data/log.txt +// install/readme.txt + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extractlist"> @@ -385,9 +587,9 @@ </funcsynopsis> <para> This method extract from the archive only the files indicated in the - <parameter>$filelist</parameter>. These files are extracted in the current + <parameter>filelist</parameter>. These files are extracted in the current directory or in the directory indicated by the optional <parameter> - $path</parameter> parameter. + path</parameter> parameter. </para> <para> Parameter @@ -419,6 +621,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>extractModify()</title> + <programlisting role="php"> + <![CDATA[ +// tarname.tar with files : +// dev/data/file.txt +// dev/data/log.txt +// readme.txt + +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->extractList("dev/data/file.txt readme.txt", "install", + "dev"); + +// Files will be extracted there : +// install/data/file.txt +// install/readme.txt + ]]> + </programlisting> + </example> </refsect1> </refentry>
Index: peardoc/en/packages/file/archive-tar.xml diff -u peardoc/en/packages/file/archive-tar.xml:1.4 peardoc/en/packages/file/archive-tar.xml:1.5 --- peardoc/en/packages/file/archive-tar.xml:1.4 Sun Feb 10 18:00:44 2002 +++ peardoc/en/packages/file/archive-tar.xml Sat Feb 16 09:16:36 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="packages.file.archive-tar"> <refnamediv> <refname>Archive_Tar</refname> @@ -24,12 +24,12 @@ <itemizedlist> <listitem> <para> - <parameter>$tarname</parameter> - the name of the tar archive to create + <parameter>$tarname</parameter> - the name of the tar archive to work with </para> </listitem> <listitem> <para> - <parameter>$compress</parameter> - if true, the archive will be + <parameter>$compress</parameter> - if true, indicates that the archive is gezip(ped). Default is <parameter>false</parameter>. </para> </listitem> @@ -48,9 +48,9 @@ <para> This method creates the archive file and add the listed files or directories. - If a file with the same name exist and is writable, it is replaced - by the new tar. - The method return false and a PEAR error text. + If a file with the same tarname exist and is writable, it is replaced + by the new tar (it is not an 'add' but a 'create'). If a file exists and is write protected or is a folder, + the method return false and a PEAR error text. The list can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a @@ -75,11 +75,43 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success, <parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + + <example> + <title>create()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling +$v_list[0]="file.txt"; +$v_list[1]="data/"; // Optional '/' at the end +$v_list[2]="file.log"; +$tar_object->create($v_list); + ]]> + </programlisting> + </example> + <para> + In this example a not compressed Tar archive is created. The files 'file.txt' and 'file.log' are + added, all the directory 'data' is added. + </para> + <example> + <title>create()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling +$tar_object->create("file.txt data/ file.log"); + ]]> + </programlisting> + </example> + <para> + In this example a compressed Tar archive is created. The same files and directory are added, + but without using an array. + </para> </refsect1> <refsect1 id="packages.file.archive-tar.add"> @@ -91,11 +123,10 @@ </funcprototype> </funcsynopsis> <para> - This method add the files / directories that are listed in $p_filelist in - the archive. If the archive does not exist it is created. + This method add the files / directories that are listed in $filelist in + the existing archive. If the archive does not exist it is created. The files and directories listed are only added at the end of the archive, even if a file with the same name is already archived. - The method return false and a PEAR error text. </para> <para> Parameter @@ -114,11 +145,23 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success, <parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + <example> + <title>add()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; // Optional '/' at the end +$v_list[2]="log/file.log"; +$tar_object->add($v_list); + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extract"> @@ -130,7 +173,29 @@ </funcprototype> </funcsynopsis> <para> - Extracts the files to the archive into the given path. + Extracts the files from the archive into the given path. + </para> + <para> + While extracting a file : If the file already exists it is replaced + without looking for last modification date. + If the file already exists and is write + protected, the extraction is aborted. + If a directory with the same name already + exists, the extraction is aborted. + </para> + <para> + While extracting a directory, if a file with the same name already + exists, the extraction is aborted. + While extracting a file/directory if the destination directory exist + and is write protected, or does not exist but can not be created, + the extraction is aborted. + If after extraction an extracted file does not show the correct + stored file size, the extraction is aborted. + </para> + <para> + When the extraction is aborted, a PEAR error text is set and false + is returned. However the result can be a partial extraction that may + need to be manually cleaned. </para> <para> Parameter @@ -148,11 +213,20 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success,<parameter>false</parameter> on error + success, <parameter>false</parameter> and a PEAR error text on error </para> </listitem> </itemizedlist> </para> + <example> + <title>extract()</title> + <programlisting role="php"> + <![CDATA[ +$tar = new Archive_Tar('archive.tgz', true); +$result = $tar->extract('destination_folder'); + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.listcontent"> @@ -164,18 +238,70 @@ </funcprototype> </funcsynopsis> <para> - Lists the files of the archive + Lists the files and the directories of the archive. + </para> + <para> + The result is an array, each entry representing a file or folder. + The array is not sorted, so the index shows the position of the file/dir in the + archive. + </para> + <para> + Each entry has the following informations : + <itemizedlist> + <listitem> + <para> + $file[filename] : Name and path of the file/dir. + </para> + <para> + $file[mode] : File permissions (result of fileperms()) + </para> + <para> + $file[uid] : user id + </para> + <para> + $file[gid] : group id + </para> + <para> + $file[size] : filesize + </para> + <para> + $file[mtime] : Last modification time (result of filemtime()) + </para> + <para> + $file[typeflag] : "" for file, "5" for directory + </para> + </listitem> + </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> - <parameter>array</parameter> - a list of the files + <parameter>array</parameter> - a list of the files/directories properties </para> </listitem> </itemizedlist> </para> + <example> + <title>listContent()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +if (($v_list = $tar_object->listContent()) != 0) + for ($i=0; $i<sizeof($v_list); $i++) { + echo "Filename :'".$v_list[$i][filename]."'<br>"; + echo " .size :'".$v_list[$i][size]."'<br>"; + echo " .mtime :'".$v_list[$i][mtime]."' (". + date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; + echo " .mode :'".$v_list[$i][mode]."'<br>"; + echo " .uid :'".$v_list[$i][uid]."'<br>"; + echo " .gid :'".$v_list[$i][gid]."'<br>"; + echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; + } + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.addmodify"> @@ -193,7 +319,9 @@ <para> This method add the files or directories listed in <parameter> filelist</parameter> at the end of the existing archive. - If the archive does not yet exists it is created. + </para> + <para> + If the archive does not exists it is created. If a file or directory is already in the archive it will only be added at the end of the archive. There is no update of the existing archived file or directory. However while extracting the archive, the last file will @@ -204,16 +332,16 @@ ignored. </para> <para> - The path indicated in <parameter>$remove_dir</parameter> will be removed from + The path indicated in <parameter>remove_dir</parameter> will be removed from the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') - The path indicated in <parameter>$add_dir</parameter> will be added at the + The path indicated in <parameter>add_dir</parameter> will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive - for extraction in a different path than the origin files are. + for extraction in a different path than the original path. </para> <para> Parameter @@ -241,7 +369,7 @@ <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> on - success,<parameter>false</parameter> on error + success, <parameter>false</parameter> on error </para> </listitem> </itemizedlist> @@ -250,9 +378,35 @@ <title>addModify()</title> <programlisting role="php"> <![CDATA[ - $tar = new Archive_Tar('archive.tgz', true); - $result = $tar->addModify('data/file.txt', 'user', 'data'); - // File will be added in the archive like : 'user/file.txt' +$tar_object = new Archive_Tar("tarname.tar"); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->addModify($v_list, "install"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/file.log + ]]> + </programlisting> + </example> + <example> + <title>addModify()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tar"); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->addModify($v_list, "install", "dev"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/log/file.log ]]> </programlisting> </example> @@ -272,11 +426,14 @@ </funcsynopsis> <para> This method creates the archive file and add the listed files or - directories. If the file already exists and is writable, it is replaced + directories. + </para> + <para> + If the file already exists and is writable, it is replaced by the new tar. It is a create and not an add. If the file exists and is read-only or is a directory it is not replaced. The path add/remove ability enables the user to prepare an archive - for extraction in a different path than the origin files are. + for extraction in a different path than the origin files are (see Archive_Tar::addModify()). </para> <para> Parameter @@ -309,6 +466,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>createModify()</title> + <programlisting role="php"> + <![CDATA[ +$tar_object = new Archive_Tar("tarname.tgz", true); +$tar_object->setErrorHandling(PEAR_ERROR_PRINT); +$v_list[0]="dev/file.txt"; +$v_list[1]="dev/data/"; +$v_list[2]="log/file.log"; +$tar_object->createModify($v_list, "install", "dev"); +// files are stored in the archive as : +// install/file.txt +// install/data +// install/data/file1.txt +// install/data/... all the files and sub-dirs of data/ +// install/log/file.log + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extractmodify"> @@ -323,24 +499,31 @@ </funcsynopsis> <para> This method extract all the content of the archive in the directory - indicated by <parameter>$path</parameter>. When relevant the memorized + indicated by <parameter>path</parameter>. When relevant the memorized path of the files or directories can be modified by removing the - <parameter>$remove_path</parameter> path at the beginning of the - file or directory path. While extracting a file, if the directory path - does not exists it is created. While extracting a file, if the file already - exists it is replaced without looking for last modification date. - while extracting a file, if the file already exists and is write + <parameter>remove_path</parameter> path at the beginning of the + file or directory path. + </para> + <para> + While extracting a file : If the file already exists it is replaced + without looking for last modification date. + If the file already exists and is write protected, the extraction is aborted. - while extracting a file, if a directory with the same name already + If a directory with the same name already exists, the extraction is aborted. - while extracting a directory, if a file with the same name already + </para> + <para> + While extracting a directory, if a file with the same name already exists, the extraction is aborted. - while extracting a file/directory if the destination directory exist + While extracting a file/directory if the destination directory exist and is write protected, or does not exist but can not be created, the extraction is aborted. If after extraction an extracted file does not show the correct stored file size, the extraction is aborted. - In such cases, the result can be a partial extraction that may + </para> + <para> + When the extraction is aborted, a PEAR error text is set and false + is returned. However the result can be a partial extraction that may need to be manually cleaned. </para> <para> @@ -369,6 +552,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>extractModify()</title> + <programlisting role="php"> + <![CDATA[ +// tarname.tar with files : +// dev/data/file.txt +// dev/data/log.txt +// readme.txt + +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->extractModify("install", "dev"); + +// Files will be extracted there : +// install/data/file.txt +// install/data/log.txt +// install/readme.txt + ]]> + </programlisting> + </example> </refsect1> <refsect1 id="packages.file.archive-tar.extractlist"> @@ -385,9 +587,9 @@ </funcsynopsis> <para> This method extract from the archive only the files indicated in the - <parameter>$filelist</parameter>. These files are extracted in the current + <parameter>filelist</parameter>. These files are extracted in the current directory or in the directory indicated by the optional <parameter> - $path</parameter> parameter. + path</parameter> parameter. </para> <para> Parameter @@ -419,6 +621,25 @@ </listitem> </itemizedlist> </para> + <example> + <title>extractModify()</title> + <programlisting role="php"> + <![CDATA[ +// tarname.tar with files : +// dev/data/file.txt +// dev/data/log.txt +// readme.txt + +$tar_object = new Archive_Tar("tarname.tar"); +$tar_object->extractList("dev/data/file.txt readme.txt", "install", + "dev"); + +// Files will be extracted there : +// install/data/file.txt +// install/readme.txt + ]]> + </programlisting> + </example> </refsect1> </refentry>