OpenArchive

From TotalcmdWiki
Jump to: navigation, search

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