[英]Does FindFirstFile/FindNextFile API pair cache results returned?
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());
What happens if while I'm still in my do/while
loop the contents of the folder change? 如果我仍在
do/while
循环时文件夹的内容发生更改,会发生什么情况? Say, a new file or a folder is added, altered or removed. 假设添加,更改或删除了新文件或文件夹。 Is that reflected in the results returned by
FindNextFile
? 这是否反映在
FindNextFile
返回的结果中?
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). 一个快速的测试案例表明,FindFirstFile不会将结果缓存在运行Windows 7的本地文件系统上。但是,一旦调用FindNext,结果就被缓存了(不完全,只有一点点)。 But since this is not documented in the Windows SDK, it must be seen as an implementation detail, which could change at any time.
但是,由于Windows SDK中未记录此内容,因此必须将其视为实现细节,并且可以随时更改。 So write your code in a way that it does not depend on this behavior.
因此,以不依赖此行为的方式编写代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.