Edit report at http://bugs.php.net/bug.php?id=39234&edit=1

 ID:                 39234
 Updated by:         rquadl...@php.net
 Reported by:        RQuadling at GMail dot com
 Summary:            Retrieve short names to files
-Status:             Assigned
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Filesystem function related
 Operating System:   Windows only
 PHP Version:        *
 Assigned To:        pajoye
 Block user comment: N
 Private report:     N

 New Comment:

As PHP now uses another feature of cmd.exe, this allows all elements of the 

command line (programs and parameters) to be quoted quite happily.



As such, this request is no longer needed.


Previous Comments:
------------------------------------------------------------------------
[2006-10-23 12:39:29] RQuadling at GMail dot com

http://msdn.microsoft.com/library/en-us/fileio/fs/getfullpathname.asp and

http://msdn.microsoft.com/library/en-us/fileio/fs/getshortpathname.asp



(Maybe these will fit?)

------------------------------------------------------------------------
[2006-10-23 12:37:56] RQuadling at GMail dot com

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 this bug report at http://bugs.php.net/bug.php?id=39234&edit=1

Reply via email to