Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting for file exclusive access before File action
#2
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.5

;info: the d.FileSize is for Firefox, which at first creates empty file, then downloads to other file...

2. Modified.

3. Why don't use zip?


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)