svn: /pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ ReleaseFileBrowser.php

[email protected] (Michael Gauthier)
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
gauthierm                                Mon, 05 Jul 2010 19:31:51 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=301008

Log:
Clean up release file browser a little bit. Trailing slash on Main::channel_path is now optional.

Changed paths:
    U   pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php

Modified: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php	2010-07-05 17:03:02 UTC (rev 301007)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php	2010-07-05 19:31:51 UTC (rev 301008)
@@ -1,5 +1,7 @@
 <?php
+
 namespace PEAR2\SimpleChannelFrontend;
+
 class ReleaseFileBrowser
 {
     public $options;
@@ -8,12 +10,14 @@

     public $internal_file;

-    function __construct($options = array())
+    public function __construct($options = array())
     {
-        $file = Main::$channel_path.'/get/'.$options['release'];
-        if (!file_exists($file)
-            || dirname($file) != Main::$channel_path.'/get') {
-            throw new \Exception('Cannot find the package. '.$file);
+        $root = rtrim(Main::$channel_path, DIRECTORY_SEPARATOR);
+        $root = $root . DIRECTORY_SEPARATOR . 'get';
+        $file = $root . DIRECTORY_SEPARATOR . $options['release'];
+
+        if (!file_exists($file) || dirname($file) != $root) {
+            throw new \Exception('Cannot find the package ' . $file . '.');
         }

         $this->release = new \PharData($file);
@@ -29,4 +33,4 @@

     }

-}
\ No newline at end of file
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.