PHP in Windows: Comparing Short & Long Names
Posted: Tue Feb 16, 2010 5:40 pm
Hi
What is the best approach in determining if two Windows file or directory locations are the same?
In Windows, file and directory paths can be given in either long or short names.
A long file name is considered to be any file name that exceeds the short MS-DOS (also called 8.3) style naming convention.
See: MSDN Short vs. Long Names
My issue is trying to find a PHP way of comparing if a long name and a short name are the same location.
For example, these are the same directory locations:
Short name: C:\Users\A-JETA~1.SEA\AppData\Local\Temp\
Long name: C:\Users\a-jetann.SEATTLE\AppData\Local\Temp\
I tried to be tricky with the following code, but this did not work:
Thanks
Jeff in Seattle
What is the best approach in determining if two Windows file or directory locations are the same?
In Windows, file and directory paths can be given in either long or short names.
A long file name is considered to be any file name that exceeds the short MS-DOS (also called 8.3) style naming convention.
See: MSDN Short vs. Long Names
My issue is trying to find a PHP way of comparing if a long name and a short name are the same location.
For example, these are the same directory locations:
Short name: C:\Users\A-JETA~1.SEA\AppData\Local\Temp\
Long name: C:\Users\a-jetann.SEATTLE\AppData\Local\Temp\
I tried to be tricky with the following code, but this did not work:
Code: Select all
$oDirShort = dir($strDirShort);
$oDirLong = dir($strDirLong);
$strDirShortPath = $oDirShort->path;
$strDirLongPath = $oDirLong->path;
return strcasecmp($strDirShortPath, $strDirLongPath) == 0;Jeff in Seattle