Re: fix to spaces in path
| From: | Stan Lemon | Date: | Sat, 02 Aug 2003 18:57:02 +0000 |
| Subject: | Re: fix to spaces in path | ||
| References: | 1 | Groups: | php.pear.dev php.pear.general php.pear.qa |
| Request: | Send a blank email to pear-dev+get-19156@lists.php.net to get a copy of this message | ||
It is definitly time this has been taken care of. This patch will allow for us Windows uers to not be forced to use PEAR in places we don't want to. I've talked with Greg about this before, and am very glad to see that a fix for it is out.
I'll test it later this evening, and I will say this, it is very needed, and about time PEAR becomes fully usable for Windows folk.
- Stan
Greg Beaver wrote:
This is your gadfly speaking. I'd like to commit the patch that fixes the spaces in path issue. Perhaps a show of hands in favor of fixing this problem would help move things along? Here is a list of the problems with spaces in paths that are solved by this fix: - pear install to a subdirectory of "C:\Program Files" will not work. "C:\Program Files" is the most commonly used install directory on windows - pear package will not work in any subdirectory containing spaces, and will create and possibly overwrite folders of the same name as the suffix. So if you have 2 directories "C:\Web" and C:\Web Pages", the pear package command will overwrite the contents of C:\Web and fail with a cryptic error message about not being able to copy a random file with .tmp pre-pended to it - the new publicweb role which is proposed will not allow installation to "C:\Program Files\Apache Group", the default Apache location on windows. backwards compatibility issues: none - this patch is internal, and uses pre-programmed features of the same functions to do the job. API issues: none - no changes are visible to private or public functions, no other code need be changed. All in favor of fixing these bugs please +1, this will at least start the ball rolling. For those wishing to test or review this fix, I've attached the patch Greg ------------------------------------------------------------------------ Index: pear/PEAR/Common.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Common.php,v retrieving revision 1.93 diff -u -r1.93 Common.php --- pear/PEAR/Common.php 12 Jul 2003 15:15:38 -0000 1.93 +++ pear/PEAR/Common.php 29 Jul 2003 18:25:11 -0000 @@ -156,7 +156,12 @@$tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; while ($file = array_shift($tempfiles)) { if (@is_dir($file)) { - System::rm("-rf $file"); + $options = + array( + '-rf', + $file, + ); + System::rm($options); } elseif (file_exists($file)) { unlink($file); }@@ -198,7 +203,12 @@function mkDirHier($dir) { $this->log(2, "+ create dir $dir"); - return System::mkDir("-p $dir"); + $options = + array( + '-p', + $dir, + ); + return System::mkDir($options); } // }}}@@ -242,11 +252,12 @@function mkTempDir($tmpdir = '') { if ($tmpdir) { - $topt = "-t $tmpdir "; + $topt = array('-t', $tmpdir); } else { - $topt = ''; + $topt = array(); } - if (!$tmpdir = System::mktemp($topt . '-d pear')) { + $topt = array_merge($topt, array('-d', 'pear')); + if (!$tmpdir = System::mktemp($topt)) { return false; } $this->addTempFile($tmpdir);Index: pear/PEAR/Config.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Config.php,v retrieving revision 1.48 diff -u -r1.48 Config.php --- pear/PEAR/Config.php 3 Jul 2003 06:43:31 -0000 1.48 +++ pear/PEAR/Config.php 29 Jul 2003 18:25:11 -0000 @@ -577,7 +577,8 @@} $data = ($data === null) ? $this->configuration[$layer] : $data; $this->_encodeOutput($data); - if (!@System::mkDir("-p " . dirname($file))) { + $opt = array('-p', dirname($file)); + if (!@System::mkDir($opt)) { return $this->raiseError("could not create directory: " . dirname($file)); } if (@is_file($file) && !@is_writeable($file)) {Index: pear/PEAR/Packager.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Packager.php,v retrieving revision 1.48 diff -u -r1.48 Packager.php --- pear/PEAR/Packager.php 27 Jun 2003 10:46:53 -0000 1.48 +++ pear/PEAR/Packager.php 29 Jul 2003 18:25:12 -0000 @@ -116,7 +116,13 @@chdir($oldcwd); return $this->raiseError($new_xml); } - if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) { + $opt = + array( + '-t', + getcwd(), + '-d', + ); + if (!($tmpdir = System::mktemp($opt))) { chdir($oldcwd); return $this->raiseError("PEAR_Packager: mktemp failed"); }@@ -135,7 +141,7 @@$tar =& new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file - $ok = $tar->createModify($newpkgfile, '', $tmpdir); + $ok = $tar->createModify(array($newpkgfile), '', $tmpdir); if (PEAR::isError($ok)) { chdir($oldcwd); return $this->raiseError($ok);Index: pear/PEAR/Registry.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Registry.php,v retrieving revision 1.46 diff -u -r1.46 Registry.php --- pear/PEAR/Registry.php 7 Jul 2003 15:42:58 -0000 1.46 +++ pear/PEAR/Registry.php 29 Jul 2003 18:25:13 -0000 @@ -146,7 +146,11 @@function _assertStateDir() { if (!@is_dir($this->statedir)) { - if (!System::mkdir("-p {$this->statedir}")) { + $opt = array( + '-p', + $this->statedir, + ); + if (!System::mkdir($opt)) { return $this->raiseError("could not create directory '{$this->statedir}'"); } }Index: pear/PEAR/Remote.php =================================================================== RCS file: /repository/php-src/pear/PEAR/Remote.php,v retrieving revision 1.41 diff -u -r1.41 Remote.php --- pear/PEAR/Remote.php 12 Jul 2003 14:25:06 -0000 1.41 +++ pear/PEAR/Remote.php 29 Jul 2003 18:25:13 -0000 @@ -56,7 +56,8 @@$id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); + $opt = array('-p', $cachedir); + System::mkdir($opt); } $filename = $cachedir . DIRECTORY_SEPARATOR . 'xmlrpc_cache_' . $id; if (!file_exists($filename)) {@@ -86,7 +87,8 @@$id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); + $opt = array('-p', $cachedir); + System::mkdir($opt); } $filename = $cachedir.'/xmlrpc_cache_'.$id;