Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determining When a File Is Ready
#2
Found in Archive.

Function WaitForFileReady
Code:
Copy      Help
;/
function $_file [^waitmax]

;Waits until file exists, is not empty, and is not locked.

;waitmax - max number of seconds to wait. 0 is infinite.


if(waitmax<0 or waitmax>2000000) end ES_BADARG
opt waitmsg -1
int wt(waitmax*1000) t1(GetTickCount)

Dir d
rep
,if d.dir(_file) and d.FileSize
,,__HFile f.Create(_file OPEN_EXISTING); err
,,if(f) f.Close; break
,
,if(wt>0 and GetTickCount-t1>=wt) end "wait timeout"
,0.1

;info: the d.FileSize is for apps that at first create empty file, close it, then later open again and write.


Messages In This Thread
Determining When a File Is Ready - by Davider - 09-01-2026, 05:10 AM
RE: Determining When a File Is Ready - by Gintaras - 09-01-2026, 07:15 AM
RE: Determining When a File Is Ready - by Davider - 09-01-2026, 07:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)