[Qt-interest] How to wait <N> ms for file creation/deletion to succeed?
Stephan Rose
kermos at somrek.net
Mon Dec 29 20:49:03 CET 2008
On Mon, 2008-12-29 at 14:17 -0200, Thiago Macieira wrote:
> Robert Hairgrove wrote:
> >What is the proper (i.e. platform-independent) way to sleep and poll for
> >a file operation to finish?
> >
> >I am encrypting/decrypting a file, writing the results to a temporary
> >file, deleting the original file and renaming the temporary file to the
> >one I just deleted. From past experience I know that timing sometimes
> >causes trouble. For example, on Windows you can call the API function
> >sleep(). There are some sleep() functions in QThread, but I think they
> >are not accessible from outside the thread object's code (they are
> >declared static protected).
>
> Hi Robert,
>
> Where are you seeing such situations?
I can easily imagine one scenario if he's dealing with image files or
any other kind of file that windows creates thumbnails from.
If you were to create a temporary file that is an image and the happen
to have the same directory open in explorer, when the file is created
explorer will go and thumbnail it. If at that same moment the app tries
to move the file it will fail due the fact that the file is currently
being accessed by explorer.
Stephan
More information about the Qt-interest-old
mailing list