什么是windows中的lstat()替代品?

在linux中,当stat()与断开的链接文件一起使用时,它会以-1失败。 所以我使用了成功的lstat()

对于Windows中的相同情况, _stat()失败并出现断开的快捷方式,但Windows中没有_lstat() 。 请帮助在windows中找到lstat()的替代方案。

可能是GetFileAttributes或GetFileAttributesEx (如果我理解statlstat权限)。 引用文档:

符号链接行为 – 如果路径指向符号链接,则该函数返回符号链接的属性。

接受的答案不提供完整的stat等效。 stat结构定义为

 struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for filesystem I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ }; 

GetFileAttributes..不提供任何所有者信息(它返回WIN32_FIND_DATA对象中的数据)。 如果您需要该所有者信息,看起来您可以使用GetSecurityInfo [1]。

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa446629%28v=vs.85%29.aspx

hey _stat()或stat()也适用于破碎的快捷方式。 这就是原因,在Windows中没有像lstat(UNIX)这样的替代方案。

在Unix中,stat()因链接断开而失败,因此提供lstat来解决问题。

感谢大家的帮助。