Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix example script

git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@161073 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 42b0d2c57de02d1e5a86b7af3e6ca7744dab9020 1 parent 7d6d5a6
tony2001 authored
Showing with 17 additions and 6 deletions.
  1. +17 −6 example.php
View
23 example.php
@@ -1,11 +1,22 @@
<?
-$rar = rar_open('/www/obj.rar');
-$entries = rar_list($rar);
+$archive_name = '/full/path/to/file.rar'
+$entry_name = 'path/to/archive/entry.txt'; //notice: no slash at the beginning
+$dir_to_extract_to = '/path/to/extract/dir';
+$new_entry_name = 'some.txt';
-var_dump($entries[0]->getName());
-var_dump($entries[0]->extract('/www/test/',''));
-var_dump($entries[0]->extract('','/www/test/2.php'));
-var_dump($entries[0]->extract('','/www/test/1.php'));
+
+$rar = rar_open($archive_name) OR die('failed to open ' . $archive_name);
+$entry = rar_entry_get($rar, $entry_name) OR die('failed to find ' . $entry_name . ' in ' . $archive_name);
+
+// this will create all necessary subdirs under $dir_to_extract_to
+$entry->extract($dir_to_extract_to);
+/* OR */
+
+// this will create only one new file $new_entry_name in $dir_to_extract_to
+$entry->extract('', $dir_to_extract_to.'/'.$new_entry_name);
+
+// this line is really not necessary
+rar_close($rar);
?>
Please sign in to comment.
Something went wrong with that request. Please try again.