加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

winapi – WIN32上struct __stat64和struct _stati64有什么区别

发布时间:2020-12-14 03:57:44 所属栏目:Windows 来源:网络整理
导读:我正在研究一些代码,这些代码需要在WIN2000以后的每个版本的 Windows上运行,并且还需要使用宽文件路径. 我需要调用一些stat的变量来获取文件长度.该文件可能大于4GB. 以下是MSDN Visual Studio .NET 2003 [1]文档中的相关部分: int _stat( const char *path
我正在研究一些代码,这些代码需要在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 
);

[1] http://msdn.microsoft.com/en-us/library/14h5k7ff(v=VS.71).aspx

我无法弄清楚__stat64结构和_stati64结构之间的区别.我知道我想使用_wstat64或_wstati64,但MSDN是静默的,哪个更好.

有什么建议?

解决方法

我不是百分百肯定,但似乎:

> stat:32位时间戳,32位文件大小
> stat64:64位时间戳,32位文件大小
> stati64:64位时间戳,64位文件大小

所以你需要wstati64.

这来自MSDN上的以下段落:

The date stamp on a file can be represented if it is later than midnight,January 1,1970,and before 19:14:07 January 18,2038,UTC unless you use _stat64 or _wstat64,in which case the date can be represented up till 23:59:59,December 31,3000,UTC.

st_size
Size of the file in bytes; a 64-bit integer for _stati64 and _wstati64

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读