On Thu, May 21, 2015 at 1:14 PM, David Golden <x...@xdg.me> wrote:
> First, I'd want someone to check if it returns %USERPROFILE% exactly or some
> path under it.

Only tested on Win7; is seems to append a backslash to it:

Z:\>type gettemppath.pl
use strict;
use warnings;

use Win32::API;

print "$_=$ENV{$_}\n" for qw(TMP TEMP USERPROFILE);
delete $ENV{$_} for qw(TMP TEMP);
my $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N') or die;
my $buffer = " " x 280;
my $len = $GetTempPath->Call(length $buffer, $buffer);
print substr($buffer, 0, $len), "\n";

Z:\>perl gettemppath.pl
TMP=C:\Users\gecko\AppData\Local\Temp
TEMP=C:\Users\gecko\AppData\Local\Temp
USERPROFILE=C:\Users\gecko
C:\Users\gecko\

And tested separately, it will normalize forward slashes to backslashes as well.

Cheers,
-Jan

Reply via email to