From: RQuadling at GMail dot com Operating system: Windows XP SP2 PHP version: 5CVS-2006-10-23 (snap) PHP Bug Type: Feature/Change Request Bug description: Retrieve short names to files.
Description: ------------ Hello. (I was required to pick a version, but that is not really relevant). This issue extends from a bug/feature of the Windows command shell executable (cmd.exe) which only allows a single set of double quotes to be used when being used with the /C option. e.g. <?php // Fine exec('"C:\Program Files\Some Dir\Some Program" C:\somefile.txt'); // Not fine exec('"C:\Program Files\Some Dir\Some Program" "C:\some file with a space in the name.txt"'); ?> You get an error which is the same at the command prompt. These work (the parameter is useless). C:\windows\system32\calc.exe 123 "C:\windows\system32\calc.exe" 123 C:\windows\system32\calc.exe "123" "C:\windows\system32\calc.exe" "123" cmd /c C:\windows\system32\calc.exe 123 cmd /c "C:\windows\system32\calc.exe" 123 cmd /c C:\windows\system32\calc.exe "123" But this doesn't work at the command line. cmd /c "C:\windows\system32\calc.exe" "123" You get the error ... 'C:\windows\system32\calc.exe" "123' is not recognized as an internal or external command, operable program or batch file. So, whilst this isn't a PHP bug, PHP could certainly help get around the problem. My proposal is to either extend the PHP function realpath() to allow for a boolean parameter to indicate the short name is to be returned. e.g. string realpath ( string path [, boolean return_short_name] ) or to introduce 2 new functions string shortname ( string longname ) string longname ( string shortname ) In addition, extending the SPL to have a getShortName() method. To get the shortname within MS VC++, there is a function called GetShortPathName(). There is also GetLongPathName(). References to these functions can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getshortpathname.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getlongpathname.asp DWORD GetShortPathName( LPCTSTR lpszLongPath, LPTSTR lpszShortPath, DWORD cchBuffer ); DWORD GetLongPathName( LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer ); With the shortname() function, a filename like ... C:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql.exe would become ... C:\PROGRA~1\MI6841~1\80\TOOLS\BINN\OSQL.EXE The name supplied is system dependent. I have a LOT of directories in "C:\Program Files" starting with Microsoft. 27/10/2004 15:01 <DIR> MI3AA1~1 Microsoft ActiveSync 16/03/2006 11:13 <DIR> MIAF83~1 Microsoft AntiSpyware 05/01/2005 10:02 <DIR> MIDA86~1 Microsoft Baseline Security Analyzer 23/02/2005 16:17 <DIR> MIAF01~1 Microsoft Firewall Client 27/10/2004 12:13 <DIR> MICROS~1 microsoft frontpage 06/04/2006 09:22 <DIR> MICROS~3 Microsoft IntelliPoint 06/04/2006 09:26 <DIR> MICROS~2 Microsoft IntelliType Pro 06/04/2006 10:13 <DIR> MICROS~4 Microsoft Office 29/10/2004 14:36 <DIR> MI6841~1 Microsoft SQL Server 16/11/2004 16:31 <DIR> MIAF9D~1 Microsoft Visual Studio 28/10/2004 08:44 <DIR> MIF2B0~1 Microsoft Works 23/02/2005 12:02 <DIR> MICROS~1.NET Microsoft.NET In terms of impact, making 2 new functions which are Windows only would probably be easier. -- Edit bug report at http://bugs.php.net/?id=39234&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39234&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39234&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39234&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39234&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39234&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39234&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39234&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39234&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39234&r=support Expected behavior: http://bugs.php.net/fix.php?id=39234&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39234&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39234&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39234&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39234&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39234&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39234&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39234&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39234&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39234&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39234&r=mysqlcfg