summaryrefslogtreecommitdiff
path: root/inc/Tar.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/Tar.class.php')
-rw-r--r--inc/Tar.class.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/inc/Tar.class.php b/inc/Tar.class.php
index 903f7f35c..0dc7dace2 100644
--- a/inc/Tar.class.php
+++ b/inc/Tar.class.php
@@ -53,6 +53,7 @@ class Tar {
protected $file = '';
protected $comptype = Tar::COMPRESS_AUTO;
+ /** @var resource|int */
protected $fh;
protected $memory = '';
protected $closed = true;
@@ -105,6 +106,9 @@ class Tar {
*
* The archive is closed afer reading the contents, because rewinding is not possible in bzip2 streams.
* Reopen the file with open() again if you want to do additional operations
+ *
+ * @return array
+ * @throws TarIOException
*/
public function contents() {
if($this->closed || !$this->file) throw new TarIOException('Can not read from a closed archive');
@@ -270,6 +274,7 @@ class Tar {
* Add a file to the current TAR archive using an existing file in the filesystem
*
* @todo handle directory adding
+ *
* @param string $file the original file
* @param string $name the name to use for the file in the archive
* @throws TarIOException
@@ -377,6 +382,10 @@ class Tar {
* Returns the created in-memory archive data
*
* This implicitly calls close() on the Archive
+ *
+ * @param int $comptype
+ * @param int $complevel
+ * @return mixed|string
*/
public function getArchive($comptype = Tar::COMPRESS_AUTO, $complevel = 9) {
$this->close();
@@ -395,7 +404,7 @@ class Tar {
* Note: It more memory effective to specify the filename in the create() function and
* let the library work on the new file directly.
*
- * @param $file
+ * @param string $file
* @param int $comptype
* @param int $complevel
* @throws TarIOException
@@ -522,7 +531,7 @@ class Tar {
* Decode the given tar file header
*
* @param string $block a 512 byte block containign the header data
- * @return array|bool
+ * @return false|array
*/
protected function parseHeader($block) {
if(!$block || strlen($block) != 512) return false;
@@ -536,6 +545,7 @@ class Tar {
$header = @unpack("a100filename/a8perm/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $block);
if(!$header) return false;
+ $return = array();
$return['checksum'] = OctDec(trim($header['checksum']));
if($return['checksum'] != $chks) return false;
@@ -570,7 +580,7 @@ class Tar {
/**
* Cleans up a path and removes relative parts, also strips leading slashes
*
- * @param string $p_dir
+ * @param string $path
* @return string
*/
public function cleanPath($path) {
@@ -590,7 +600,7 @@ class Tar {
/**
* Checks if the given compression type is available and throws an exception if not
*
- * @param $comptype
+ * @param int $comptype
* @throws TarIllegalCompressionException
*/
protected function compressioncheck($comptype) {
@@ -624,8 +634,14 @@ class Tar {
}
}
+/**
+ * Class TarIOException
+ */
class TarIOException extends Exception {
}
+/**
+ * Class TarIllegalCompressionException
+ */
class TarIllegalCompressionException extends Exception {
}