webfile

 Function Name  Parameter  Return  Explain
 seek number offset, from number Repositions the pointer in an open file.

Return Value:
The new byte offset from the beginning of the file if the requested position is legal; otherwise, the value is undefine.

Parameters:

Offset:

Offset in bytes to move the read/write pointer in the file.

from:

Relative reference for the offset. Must be one of the following values:

FILE_BEGIN:
Move the file pointer Offset bytes forward from the beginning of the file.

FILE_CURRENT:
Move the file pointer Offset bytes from the current position in the file.

FILE_END:
Move the file pointer Offset bytes from the end of the file. Offset must be negative to seek into the existing file; positive values will seek past the end of the file.
 setDestFile string filename boolean Specify a destination file. The read function will download bytes and write to the destination file.
Return True if successful, otherwise return False.
 read [ number cacheSize ] number Read bytes for remote file and write the bytes to the destination file. Return the number of bytes readed; return 0 if the end of file was reached.
Parameters:

cacheSize: ( 4 ~ 256 )

Default is 16 if absent. Function will try to read cacheSize K bytes for this call. Big cacheSize is efficient, but need more time to wait function return.
 release None None Release self.
You must call the release function for each webfile returned by websession.openURL function.

Remark:
You must first execute " require 'scripts\\webfile' " command to use this class.

Example:

-- download and load scene

require 'scripts\\websession'
require 'scripts\\webfile'

local szURL='http://www.awingsoft.com/zips/Painter.exe'

ses=websession.new()
file=ses.openURL(szURL)
local destfilename=GetTempFileName()
file.setDestFile(destfilename)

local filesize=file.seek(0,FILE_END)
file.seek(0,FILE_BEGIN)

local bytescount=0

local readbytes=file.read()

while (readbytes>0) do
bytescount=bytescount + readbytes
readbytes=file.read()
end


file.release()
ses.release()

Unpack(destfilename)

local path, scefn, ver = GetPackageInfo(szURL,destfilename)

SetBasePath(path)
wnd.SetCurrentDirectory(path)
LoadScene(path..'\\'..scefn)