[Perl][文件操作]判断文件是否为符号链接,Unicode路径

Win32API::File 判断文件/文件夹是否为符号链接

Win32::Unicode 好像无法做这方面的判断,只能判断是否为目录、文件、文件是否存在。

Win32API::File 则支持 GetFileAttributesW

GetFileAttributes 的返回值常量列表,可参考 MSDN 官方文档:

https://msdn.microsoft.com/en-us/library/gg258117(v=vs.85).aspx

Code: [全选] [展开/收缩] [Download] (Untitled.pl)

use utf8;
use Encode;
use Win32API::File qw(:ALL);
 
my $path = "D:\\Extra\\中文";
my $code = GetFileAttributesW( encode('utf16-le', $path) ."\x00\x00"  );
if ( ($code & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT)
{
    print "$code, symbolic link\n";
}