Public Types | |
enum | { RES_MAGIC = 0x3020c49b, RES_VERSION = 1 } |
Public Member Functions | |
Resources (SeekableIO *pcStream) | |
Construct an os::Resources object from a seekable data stream. | |
Resources (int nImageID) | |
Construct a os::Resources from a executable or DLL image ID. | |
Resources (SeekableIO *pcStream, off_t nResOffset, bool bCreate=false) | |
Construct a os::Resources object from a seekable data stream. | |
~Resources () | |
void | DetachStream () |
Detach the data-stream to avoid it being deleted by the constructor. | |
int | GetResourceCount () const |
Get the number of resources embedded in this archive. | |
String | GetResourceName (uint nIndex) const |
Get the name of a specified resource. | |
String | GetResourceType (uint nIndex) const |
Get the mime-type of a specified resource. | |
ssize_t | GetResourceSize (uint nIndex) const |
Get the size of a specified resource. | |
ssize_t | ReadResource (const String &cResName, void *pBuffer, String *pzResType, ssize_t nSize) |
Read data from a named resource. | |
ResStream * | GetResourceStream (const String &cName) |
Get a seekable-data stream referencing a resource's data. | |
ResStream * | GetResourceStream (uint nIndex) |
Get a seekable-data stream referencing a resource's data. | |
ResStream * | CreateResource (const String &cName, const String &cType, ssize_t nSize) |
Create a new resource. | |
status_t | FindExecutableResource (SeekableIO *pcStream, off_t *pnOffset, ssize_t *pnSize, const char *pzSectionName=NULL) |
Locate the resource section in an AtheOS executable or DLL. | |
Classes | |
class | Private |
Resources::Resources | ( | SeekableIO * | pcFile | ) |
pcFile
object will be deleted by the os::Resources when the os::Resources object is deleted unless it is manually detached by calling the DetachStream() member. pcFile | A readable stream referencing a valid resource archive or a valid AtheOS executable/DLL with a resource section.This stream will be deleted by the archive unless an exception is thrown from this constructor or it is detached from the archive with DetachStream(). |
Resources::Resources | ( | int | nImageID | ) |
nImageID
can be obtained with the get_image_id() syscall. get_image_id() will return the image ID of the DLL or executable in which the calling function live. nImageID | A valid handle to a DLL or executable loaded by this process. |
Resources::Resources | ( | SeekableIO * | pcFile, | |
off_t | nResOffset, | |||
bool | bCreate = false | |||
) |
bCreate
parameter is true a resource archive header will be written to the file and you can add resources to it with the CreateResource() member. All old resources will be deleted when creating an archive. pcFile
object will be deleted by the os::Resources when the os::Resources object is deleted unless it is manually detached by calling the DetachStream() member. pcFile | The stream to operate on. This can be an empty file if the bCreate argument is true. This stream will be deleted by the archive unless an exception is thrown from this constructor or it is detached from the archive with DetachStream(). | |
nResOffset | The file-position where the resource archive lives or where a new resource archive should be written. | |
bCreate | If true a new archive header will be written at nResOffset and new resources can be added with CreateResource(). |
Resources::~Resources | ( | ) |
void Resources::DetachStream | ( | ) |
int Resources::GetResourceCount | ( | ) | const |
String Resources::GetResourceName | ( | uint | nIndex | ) | const |
nIndex | Which resource to query. |
String Resources::GetResourceType | ( | uint | nIndex | ) | const |
nIndex | Which resource to query. |
ssize_t Resources::GetResourceSize | ( | uint | nIndex | ) | const |
nIndex | Which resource to query. |
ssize_t Resources::ReadResource | ( | const String & | cResName, | |
void * | pBuffer, | |||
String * | pcResType, | |||
ssize_t | nSize | |||
) |
cResName | The name of the resource to read. | |
pBuffer | Pointer to a buffer that will receive at most nSize bytes of data. If only the mime-type is interresting this can be a NULL pointer. | |
pcResType | Pointer to a STL string that will receive the mime-type of the resource or NULL if you don't want to receive the mime-type. | |
nSize | The maximum number of bytes to read from the stream. |
cName | The name of the resource to lookup. |
ResStream * Resources::GetResourceStream | ( | uint | nIndex | ) |
nIndex | The index (between 0 and GetResourceCount() - 1) of the resource to obtain. |
cName | The name of the new resource. The name must be unique and can be at most 255 bytes long. | |
cType | The mime-type of the stream. This is used to identify the data type that will be written to the stream. If the data don't have a mime-typed defined for it you should normally use "application/octet-stream". The mime-type must be at most 255 bytes long. | |
nSize | The number of bytes that should be allocated for this resource. |
status_t Resources::FindExecutableResource | ( | SeekableIO * | pcStream, | |
off_t * | pnOffset, | |||
ssize_t * | pnSize, | |||
const char * | pzSectionName = NULL | |||
) |
pcStream | A seekable stream referencing an AtheOS executable or DLL. | |
pnOffset | Pointer to an off_t variable that will receive the position of the first byte of the resource section within the executable. Can safely be passed as NULL if the offset is not interresting. | |
pnSize | Pointer to an ssize_t variable that will receive the size of the resource section. Can safely be passed as NULL if the size is not interresting. | |
pzSectionName | Should normally be passed as NULL (the default) but can optionally be used to specify the name of the section to be searched for. |