![]() |
Humble Framework for SkyOS |
#include <HResMgr.h>
Inheritance diagram for HResMgr:

Any files that the application requires can be stored inside the resource file, from where they will be automatically extracted when needed. Future versions of the HResMgr class will be able to 'clean up' resources, or ultimately eliminate the reliance on external files.
So why use a package (.pkg) file? First of all, because it's easy: it's just a .zip archive with a different extension, which means there are numerous tools available to create and manage the resource file during development. Secondly, the zip library is portable, fast, stable, and readily available. Thirdly, the .zip file format already has all kinds of developer goodness inside, including industry-standard compression, hierarchical file names, and the ability to add comments to files contained inside the archive.
From within any application built with the Humble Framework, using resources can be as simple as a couple of lines of code:
if (theApp.ExtractResource("Splash.jpg") != NO_ERROR) { // handle a 'resource not found' error }
This code snippet first goes out to the resource directory (currently the same directory as the resource file) and checks to see if the file has already been extracted; if so, no further work is necessary, and a success result is returned. If the file doesn't exist yet, the resource file managed by the HResMgr class—and originally opened in the HApp::Init() method—is searched for a file with the name Splash.jpg, which if found, is decompressed and written out to the resource directory. This example uses a JPEG image, but an application resource can be anything: a text file, a binary data file, even an application or another resource file! Since the .zip archive doesn't place many restrictions on what kinds of files can be stored within an archive, the HResMgr class is subsequently equally versatile.
Definition at line 72 of file HResMgr.h.
Public Member Functions | |
| ErrCode | Extract (StringPtr pstrSrc, StringPtr pstrDst=NULL) |
| Extracts a resource file. | |
| ErrCode | Open (HFilename &fsFile) |
| Opens a resource file. | |
|
||||||||||||
|
This method looks for a given source file in the .zip archive and reads in the file's contents, inflating it if needed. The resulting data is then written out to a file. Although hierarchical filename can be used, the caller is responsible for ensuring that any or all subdirectories exist.
Reimplemented from HZipFile. |
|
|
|
2006.01.09-16:37