Thanks Mikele.
2 All Nobody else intrested in file downloading lib for Blitz3D, that allow download files in background througt http request automaticaly finding proxy settings etc?
Here is source of sample:
Type FileDownloadT
Field FileHandle%
Field Completed%
Field RemoteFileName$
Field LocalFileName$
Field BytesDownloaded%
Field SizeOfFile%
End Type
DownloadFile("http://smallfreegames.com/test/Hero1.jpg", "Hero1.jpg")
DownloadFile("http://smallfreegames.com/test/Hero2.jpg", "Hero2.jpg")
DownloadFile("http://smallfreegames.com/test/screen.xml", "test.xml")
While Not (AllDownloadsCompleted() Or KeyDown(1))
Cls
i=0
For this.FileDownloadT=Each FileDownloadT
i=i+1
;If DStat%(this\FileHandle, 4)=1 Then DebugLog DStat%(this\FileHandle, 3)
Select DStat%(this\FileHandle, 4)
Case 0
Text 10,10+i*20,"File "+Str(i)+" downloading..."
Case 1
Text 10,10+i*20,"File "+Str(i)+" downloaded."
Case 2
Text 10,10+i*20,"File "+Str(i)+" failed."
End Select
Next
Flip
Delay 1
Wend
Cls
Print "All files downloaded."
WaitKey()
End
Function AllDownloadsCompleted()
For this.FileDownloadT=Each FileDownloadT
If this\Completed=False
If DStat%(this\FileHandle, 4)=False Then Return False
EndIf
Next
Return True
End Function
Function DownloadFile(URL$, LocalFileName$)
this.FileDownloadT=New FileDownloadT
this\RemoteFileName$=URL$
this\LocalFileName$=LocalFileName$
this\FileHandle=URL2File(this\RemoteFileName$,this\LocalFileName$,True)
this\SizeOfFile%=DStat(this\FileHandle,3)
DebugLog this\SizeOfFile%
this\Completed=False
Return Handle(this)
End Function
|