• Advertisement
Sign in to follow this  

delayed file access [win32]

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, on win32, when a file is created data is written and the file is closed it is not possible to access this file again immediately. It takes ca. 1 sec until access is possible. Does anyone know why that is and is there a good solution, perhaps a callback to get informed when the created file is accessible? I know that perhaps the best would be to let the file open and keep the handle, but perhaps there is another way to handle it... Thanks in advance! -- constantin

Share this post


Link to post
Share on other sites
Advertisement
Thanks, i'll take a look at it.

What I want to do:
In our project there are savegames copied and should be accessed directly afterwards, also there are meshes generated and written and should be loaded in the following step. That brings up the problem I was refering to. The program can't load the file because it's not yet accesible.

I hoped there is maybe a standard way to solve this problem..

-- constantin

Share this post


Link to post
Share on other sites
What functions are you using to access the file.

fopen/fread or CreateFile?

When using CreateFile: depending on what access you want you should limit the flags. For reading only always supply FILE_SHARE_READ.

You could also have a file open function that will try 3 or 5 times, with a sleep inside if it doesn't work.

Share this post


Link to post
Share on other sites
Quote:
Original post by conman
on win32, when a file is created data is written and the file is closed it is not possible to access this file again immediately.


What API are you using to write the file? Using the native APIs, file access is essentially immediate. Even with caching, the operating system will handle synchronisation so that multiple processes will see changes made to the file immediately, even before they may be flushed to disk.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement