vy3*_*y32 4 64-bit winapi msdn stat widechar
我正在编写一些代码,这些代码需要在自 WIN2000 以来的每个版本的 Windows 上运行,并且还需要使用宽文件路径。
我需要调用一些变体stat
来获取文件长度。该文件可能大于 4GB。
这是 MSDN Visual Studio .NET 2003[1] 文档中的相关部分:
int_stat( const char *path, 结构 _stat *缓冲区 ); int_stat64( const char *path, 结构 __stat64 *缓冲 ); int_stati64( const char *path, 结构_stati64 *缓冲区 ); int_wstat( const wchar_t *path, 结构 _stat *缓冲区 ); int_wstat64( const wchar_t *path, 结构 __stat64 *缓冲 ); int_wstati64( const wchar_t *path, 结构_stati64 *缓冲区 );
[1] http://msdn.microsoft.com/en-us/library/14h5k7ff(v=VS.71).aspx
我无法弄清楚__stat64
结构和_stati64
结构之间的区别。我知道我想使用_wstat64
或_wstati64
但 MSDN 没有提及哪个更好。
有什么建议?
以下是来自 mingw wchar.h#include
文件的 __stat64 和 _stati64 结构:
#if 已定义 (__MSVCRT__) 结构_stati64 { _dev_t st_dev; _ino_t st_ino; 无符号短 st_mode; 短 st_nlink; 短 st_uid; 短 st_gid; _dev_t st_rdev; __int64 st_size; time_t st_atime; time_t st_mtime; time_t st_ctime; }; #if __MSVCRT_VERSION__ >= 0x0601 结构体__stat64 { _dev_t st_dev; _ino_t st_ino; _mode_t st_mode; 短 st_nlink; 短 st_uid; 短 st_gid; _dev_t st_rdev; __int64 st_size; __time64_t st_atime; __time64_t st_mtime; __time64_t st_ctime; };
根据这些结构,这似乎_stat64
是一个更好的选择,而不是stati64
因为:
st_mode
是_mode_t
和不是unsigned short
_time64_t
而不是 a time_t
,因此它具有与 NTFS 文件系统可以表示的范围相同的范围,并且不会削弱到 32 位time_t
.我仍然感到困惑,但这似乎更接近正确答案。
还要注意_stat64
requires MSVCRT_VERSION
> 0x0601
,这意味着它更现代。
归档时间: |
|
查看次数: |
5273 次 |
最近记录: |