FindFirstFile/FindNextFile API 对缓存结果是否返回? [英] Does FindFirstFile/FindNextFile API pair cache results returned?

查看:29
本文介绍了FindFirstFile/FindNextFile API 对缓存结果是否返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定是否有人问过这个问题,我似乎找不到.

I'm not sure if this was asked already, I can't seem to find it.

当我进行文件夹内容枚举时,您知道通常情况:

When I'm doing a folder contents enumeration, you know the usual:

FindFirstFile();
do
{
}while(FindNextFile());

如果当我仍然在我的 do/while 循环中时文件夹的内容发生了变化,会发生什么?比如说,添加、更改或删除了一个新文件或文件夹.这是否反映在 FindNextFile 返回的结果中?

What happens if while I'm still in my do/while loop the contents of the folder change? Say, a new file or a folder is added, altered or removed. Is that reflected in the results returned by FindNextFile?

推荐答案

一个快速测试案例表明 FindFirstFile 不会在运行在 Windows 7 上的本地文件系统上缓存结果.但是一旦调用 FindNext,结果就会被缓存(不完全,只有一点点).但是,由于 Windows SDK 中没有记录这一点,因此必须将其视为实现细节,该细节可能随时更改.因此,请以不依赖于这种行为的方式编写代码.

A quick test case shows that FindFirstFile does not cache the results on a local filesystem running on Windows 7. But as soon as FindNext is called, the results are cached (not fully, only a little bit). But since this is not documented in the Windows SDK, it must be seen as an implementation detail, which could change at any time. So write your code in a way that it does not depend on this behavior.

这篇关于FindFirstFile/FindNextFile API 对缓存结果是否返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆