Permalink
Browse files

- fixed issue #4

- prepared new release
  • Loading branch information...
1 parent ca55002 commit fe70a5556326296687a34f6d01bba71b4202cb68 @koto committed Dec 16, 2010
View
@@ -1,2 +1,3 @@
*.pem
-*.phar*
+*.phar*
+*.json
@@ -0,0 +1,6 @@
+<?php
+//lets include some test file
+require_once 'test.php';
+echo "Hello from mighty phar archive!\n";
+
+
@@ -0,0 +1,6 @@
+<?php
+//lets include some test file
+require_once 'test.php';
+echo "Hello from mighty phar archive!\n";
+
+
View
@@ -13,9 +13,9 @@
<email>kkotowicz@gmail.com</email>
<active>yes</active>
</lead>
- <date>2010-10-03</date>
+ <date>2010-12-16</date>
<version>
- <release>0.5.4</release>
+ <release>0.5.5</release>
<api>0.1</api>
</version>
<stability>
View
@@ -170,15 +170,17 @@
// buildFromIterator unfortunately sucks and skips nested directories (?)
foreach ($iterator as $file) {
- if(!QUIET_MODE) {
- echo "adding " . $file . PHP_EOL;
- }
- if ($file->isFile()) {
- $phar->addFile($file, str_replace($options['src'], '', $file));
- }
- if ($file->isDir() && !$iterator->isDot()) {
- // this also doesn't work :(
- $phar->addEmptyDir(str_replace($options['src'], '', $file));
+ if (!$iterator->isDot()) {
+ if(!QUIET_MODE) {
+ echo "adding " . $file . PHP_EOL;
+ }
+ if ($file->isFile()) {
+ $phar->addFile($file, strip_from_beginning($options['src'], $file));
+ }
+ if ($file->isDir()) {
+ // this also doesn't work :(
+ $phar->addEmptyDir(strip_from_beginning($options['src'], $file));
+ }
}
}
@@ -220,6 +222,13 @@
exit(1);
}
+function strip_from_beginning($needle, $haystack) {
+ if (strpos($haystack, $needle) !== 0) // not in the beginning/not found
+ return $haystack;
+
+ return substr($haystack, strlen($needle));
+}
+
class ExcludeFilesIterator extends FilterIterator {
protected $exclude_file;
protected $exclude_path;

0 comments on commit fe70a55

Please sign in to comment.