OpenArchive: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
(clarified what a handle means, thread safety)
 
(3 intermediate revisions by one other user not shown)
Line 5: Line 5:
== Description ==
== Description ==


OpenArchive should return a unique handle representing the archive. The handle should remain valid until [[CloseArchive]] is called. If an [[Packer plugins developper errors|error]] occurs, you should return zero, and specify the [[Packer plugins developper errors|error]] by setting OpenResult member of ''ArchiveData''.
OpenArchive should return a unique "handle" representing the archive.


You can use the ''ArchiveData'' to query information about the archive being open, and store the information in ''ArchiveData'' to some location that can be accessed via the handle.
Most likely this will be some data structure or object address on heap, to and from which you can cast for every subsequent function call. A static or global structure will of course also work, but would interfere with thread safety and having multiple pack/unpack operations at the same time ([[GetBackgroundFlags]]).
Since the interface was developed around the Windows API, an actual Windows ''HANDLE'' is meant, which is defined as pointer to void (''PVOID'' → ''void*'').
Therefore use an explicit cast to ''HANDLE'' for your data.
 
The handle should remain valid until [[CloseArchive]] is called. In there you can safely delete your data, to free the heap (if you used it).
 
If an [[Packer plugins developer errors|error]] occurs, you should return zero, and specify the [[Packer plugins developer errors|error]] by setting OpenResult member of ''ArchiveData''.
 
You can use the ''ArchiveData'' structure to query information about the archive being open.
If you need that information for subsequent function calls, you should store it to some location that can be accessed via the handle.
 
 
{{backlink|Packer plugins developer guide overview|Packer plugins developer guide}}

Latest revision as of 16:39, 29 September 2015

OpenArchive should perform all necessary operations when an archive is to be opened.

 HANDLE __stdcall OpenArchive (tOpenArchiveData *ArchiveData);

Description

OpenArchive should return a unique "handle" representing the archive.

Most likely this will be some data structure or object address on heap, to and from which you can cast for every subsequent function call. A static or global structure will of course also work, but would interfere with thread safety and having multiple pack/unpack operations at the same time (GetBackgroundFlags). Since the interface was developed around the Windows API, an actual Windows HANDLE is meant, which is defined as pointer to void (PVOIDvoid*). Therefore use an explicit cast to HANDLE for your data.

The handle should remain valid until CloseArchive is called. In there you can safely delete your data, to free the heap (if you used it).

If an error occurs, you should return zero, and specify the error by setting OpenResult member of ArchiveData.

You can use the ArchiveData structure to query information about the archive being open. If you need that information for subsequent function calls, you should store it to some location that can be accessed via the handle.



Back to Packer plugins developer guide