xref: /openbsd-src/gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
1b39c5158Smillertuse strict;
2b39c5158Smillertuse Test;
3b39c5158Smillertuse Win32;
4b39c5158Smillert
5*256a93a4Safresh1BEGIN {
6*256a93a4Safresh1    Win32::CreateFile("8dot3test_canary_GetShortPathName $$");
7*256a93a4Safresh1    my $canary = Win32::GetShortPathName("8dot3test_canary_GetShortPathName $$");
8*256a93a4Safresh1    unlink("8dot3test_canary_GetShortPathName $$");
9*256a93a4Safresh1    if ( length $canary > 12 ) {
10*256a93a4Safresh1        print "1..0 # Skip: The system and/or current volume is not configured to support short names.\n";
11*256a93a4Safresh1        exit 0;
12*256a93a4Safresh1    }
13*256a93a4Safresh1}
14*256a93a4Safresh1
15b39c5158Smillertmy $path = "Long Path $$";
16b39c5158Smillertunlink($path);
17b39c5158SmillertEND { unlink $path }
18b39c5158Smillert
19b39c5158Smillertplan tests => 5;
20b39c5158Smillert
21b39c5158SmillertWin32::CreateFile($path);
22b39c5158Smillertok(-f $path);
23b39c5158Smillert
24b39c5158Smillertmy $short = Win32::GetShortPathName($path);
25b39c5158Smillertok($short, qr/^\S{1,8}(\.\S{1,3})?$/);
26b39c5158Smillertok(-f $short);
27b39c5158Smillert
28b39c5158Smillertunlink($path);
29b39c5158Smillertok(!-f $path);
30b39c5158Smillertok(!defined Win32::GetShortPathName($path));
31