Name
DefineVirtualFile -- define a virtual file inside a real file (V4.0)
Synopsis
virtfile$ = DefineVirtualFile(file$, offset, size, name$)
Function
This function allows you to define a virtual file inside another file which can be useful in several situations. Imagine you are working on a game and you want to store all data of the game in one huge resource file. Now you need to load some data from this huge resource file and that is when DefineVirtualFile() comes into play.

As parameter 1 you pass the name of the file that shall be the source of the virtual file. Parameters 2 and 3 then define the location of the virtual file inside file$. The virtual file to be created will be located inside file$ from file position offset to file position offset+size. Parameter 4 finally specifies the file name for the virtual file. The only thing that is important here is the file extension because it gives Hollywood a hint of the virtual file's type. Thus, you should make sure that you pass the correct file extension. The name does not matter, but the file extension should be passed because not all files can be easily identified by their header.

DefineVirtualFile() returns a string describing the virtual file. You can pass this string to all Hollywood functions which accept a file name. Of course, only read access is supported by virtual files. Attempting to write to virtual files will not work.

Inputs
file$
source file from which data of the virtual file shall be taken
offset
start position of the virtual file inside file$
size
length in bytes of the virtual file inside file$
name$
the name and file extension of the virtual file (see above)
Results
virtfile$
string describing the virtual file
Example
vf$ = DefineVirtualFile("hugeresource.dat", 100000, 32768, "image.png")
LoadBrush(1, vf$, {LoadAlpha = True})
The code above defines a virtual file inside "hugeresource.dat". The virtual file is of the size of 32768 bytes and starts at position 100000 inside "hugeresource.dat". The virtual file is a PNG image. After describing the virtual file, the image will be loaded with a simple call to LoadBrush().

Show TOC