I have a function that should back up the source folder by copying all the files from the source to the destination folder. The function uses a while loop controlled by FindFirstFile/ FindNextFile, then calls CopyFilefor each file found by the function Find....
Now, when the source folder is the SMB network path (regardless of whether I use the mapped drive or the UNC path), sometimes it happens that it FindNextFile“sees” the file, but CopyFilerefuses to copy the file, the error code is 2, i.e. ERROR_FILE_NOT_FOUND.
It was hard for me to believe, so I added a call _accessto the backup function, which checks for the existence of the file just before it is CopyFilecalled. The result is the same as for CopyFile, i.e. _accessreports that the file does not exist (return code is -1 and errnoequal to 2, i.e. ENOENT).
So, my main question is: how is it possible that FindFirstFile/ FindNextFile"sees" files in a network folder that they cannot see CopyFileand _access?
Additional information / diagnostics:
- A problem file is a file created immediately before starting the backup function. In particular, it works as follows: a process running on a client machine has a network connection to a process running on a server. The client process informs the server process of the creation of the file. It is assumed that it will work synchronously: only after the server process confirms that it has created the file, the client process continues to back up.
- .
CopyFile _access 4 . , - . , FindFirstFile/FindNextFile , CopyFile/_access.
, , . FindFirstFile/FindNextFile/CopyFile , API /, ?