WIN32 上 struct __stat64 和 struct _stati64 有什么区别?
我正在编写一些代码,这些代码需要在自 WIN2000 以来的每个版本的 Windows 上运行,并且还需要使用宽文件路径。
我需要调用 stat 的一些变体来获取文件长度。该文件可能大于 4GB。
以下是 MSDN Visual Studio .NET 2003[1] 文档中的相关部分:
int _stat( const char *path, struct _stat *buffer ); int _stat64( const char *path, struct __stat64 *buffer ); int _stati64( const char *path, struct _stati64 *buffer ); int _wstat( const wchar_t *path, struct _stat *buffer ); int _wstat64( const wchar_t *path, struct __stat64 *buffer ); int _wstati64( const wchar_t *path, struct _stati64 *buffer );
我可以弄清楚__stat64
结构和_stati64
结构之间的区别。我知道我想使用 _wstat64
或 _wstati64
,但 MSDN 没有说明哪个更好。
有什么建议吗?
I'm working on some code that needs to run on every version of windows since WIN2000 and also needs to work with wide file paths.
I need to call some variant of stat
to get the file length. The file may be larger than 4GB.
Here's the relevant section from the MSDN Visual Studio .NET 2003[1] documentation:
int _stat( const char *path, struct _stat *buffer ); int _stat64( const char *path, struct __stat64 *buffer ); int _stati64( const char *path, struct _stati64 *buffer ); int _wstat( const wchar_t *path, struct _stat *buffer ); int _wstat64( const wchar_t *path, struct __stat64 *buffer ); int _wstati64( const wchar_t *path, struct _stati64 *buffer );
I can't figure out the difference between the __stat64
structure and the _stati64
structure. I know that I want to use _wstat64
or _wstati64
but MSDN is silent on which is better.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是 mingw wchar.h
#include
文件中的 __stat64 和 _stati64 结构:根据这些结构,似乎
_stat64
是比stati64 更好的选择
因为:st_mode
是_mode_t
而不是unsigned short
_time64_t
而不是time_t
,因此它与 NTFS 文件系统可以表示的范围相同,并且不会削弱为 32 位time_t< /代码>。
我仍然很困惑,但这似乎更接近正确答案。
另请注意,
_stat64
需要MSVCRT_VERSION
>0x0601
,这意味着它更现代。Here are the __stat64 and the _stati64 structures from the mingw wchar.h
#include
file:According to these structures, it seems that
_stat64
is a better choice thanstati64
because:st_mode
is_mode_t
and notunsigned short
_time64_t
and not atime_t
, so it has the same range that can be expressed by the NTFS file system, and is not crippled to the 32-bittime_t
.I'm still confused, but this seems closer to the correct answer.
Notice also that the
_stat64
requiresMSVCRT_VERSION
>0x0601
, which implies that it is more modern.我不是 100% 确定,但看起来像:
stat
:32 位时间戳,32 位文件大小stat64
:64 位时间戳,32 位文件大小因此您需要
wstati64
。这来自 MSDN 上的以下段落:
和
I'm not 100% sure, but it seems like:
stat
: 32-bit timestamp, 32-bit filesizestat64
: 64-bit timestamp, 32-bit filesizestati64
: 64-bit timestamp, 64-bit filesizeSo you would need
wstati64
.This from the following paragraphs on MSDN:
and
文档说:
The documentation says: