Re: Getting short (DOS) name of file?

From: Date: Tue, 31 Dec 2002 13:31:19 +0000
Subject: Re: Getting short (DOS) name of file?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-129769@lists.php.net to get a copy of this message
On Tue, 31 Dec 2002 02:14:18 -0500, you wrote: >Thanks... thing is, it can be anything from c:\whatever.exe to >c:\program files\program name\bin\program.exe. I'll write a function >that goes to each directory in a string and does a dir /x if I have to, >but isn't there a simpler way? I don't know of anything built into PHP. There is a Win32 API call called GetShortPathName that would return the information. Maybe you can search and find a small binary that makes that API call and returns it's result. Another option is to use Perl. If you can install ActivePerl on your server you can use the following script: #!/usr/bin/perl use strict; use warnings; use Win32; use Getopt::Std; use File::Basename; our ($opt_p); getopts('p:'); my $path = $opt_p; if (!defined($path) || $path eq '') { print "Please specify a path with the -p option, for example: ". basename($0)." -p \"c:\\my long path\"\n"; exit; } my $short_path = Win32::GetShortPathName($path); print $short_path; exit 0; HTH...

« previous php.general (#129769) next »