Jump to content

File System

Any file can be retrieved from the abstract file system by using the "abstract::" protocol as follows:
LoadMesh("abstract::oildrum.obj")
This will search for and return the file "oildrum.obj" if it exists anywhere in the directory structure.
One caveat of this system is that only one file of any name will be cached by the engine. If another copy of "oildrum.obj" exists in another registered directory, there is no way of knowing which version will be loaded. Care should be taken to avoid redundant files.
If the precise file path is known, it is not necessary to rely on the abstract file system. For example, a mesh could be loaded as follows:
LoadMesh("Meshes/Industrial/oildrum.obj")
If the same asset (of the same filename) is loaded multiple times (e.g. LoadMesh("abstract::oildrum.obj"), ...., LoadMesh("abstract::oildrum.obj")), it'll actually be copied into memory only once and any lather loading will just return a reference to the already loaded asset. An asset will be freed if there's no more reference to it.

File Packages
Leadwerks Engine 2 can load files directly from zip archives, without creating any temporary files on the hard drive. Because zip files are so commonly used, and inadvertant loading of zip packages might cause confusion, the engine only reads zip packages renamed with the file extension "pak". It is possible to specify the exact path of a packed file by using the "zip::" protocol as follows:
LoadMesh("zip::meshes.pak//oildrum.obj")
The abstract file system will automatically cache and retrieve files from zip packages.

Online Files
Leadwerks Engine 2.1 can load files from an online server using the "http" protocol as follows:
LoadMesh("http::www.leadwerks.com/oildrum.obj")
Online files cannot be cached in the abstract file system, nor can they be loaded from zip packages online. Online files may not work if connected through a proxy internet connection.

Cache Files
Leadwerks Engine 2.1 introduces the "cache" file protocol. This will load a file from any location and copy it to a local "cache" folder. This local cached file is then returned. If the file date of the source file is older or the same as the local cached file, the file will not be copied.
Cache files can be copied from any location, including remote servers. To cache an online file, the "http" protocol must be used as follows:
LoadModel("cache::http::myserver.com/files/oildrum.gmf")
If "oildrum.gmf" does not exist in the "cache" folder, the file will be downloaded and loaded. If the cached copy of the file is older than the source copy, the cached copy will be overwritten with the new one. If the cached copy is newer or the same age as the source copy, the cached copy will be loaded without updating.

Commmands

AbstractPath
RegisterAbstractPath
SetZipStreamPassword
  • You cannot add records