Rar C Library Reference

Rar

A freeware class for extracting RAR archives.

This class is only available in Chilkat implementations for the Windows operating system.

Create/Dispose

HCkRar CkRar_Create(void);

Creates an instance of the CkRar object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkRar_Dispose(HCkRar handle);

Objects created by calling CkRar_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

C "Properties"

void CkRar_getLastErrorHtml(HCkRar cHandle, HCkString retval);

Error information in HTML format for the last method called.

void CkRar_getLastErrorText(HCkRar cHandle, HCkString retval);

Error information in plain-text format for the last method called.

void CkRar_getLastErrorXml(HCkRar cHandle, HCkString retval);

Error information in XML format for the last method called.

long CkRar_getNumEntries(HCkRar cHandle);

The number of files and directories in the RAR archive.

BOOL CkRar_getUtf8(HCkRar cHandle);
void CkRar_putUtf8(HCkRar cHandle, BOOL newVal);

To be documented soon...

C "Methods"

BOOL CkRar_Close(HCkRar cHandle);

Closes a RAR archive.

Returns TRUE for success, FALSE for failure.

BOOL CkRar_FastOpen(HCkRar cHandle, const char *filename);

Opens a RAR archive. The filename may include an absolute or relative directory path. This method does not iterate over the entries in the RAR archive. The NumEntries property will remain at 0 after FastOpen is called. FastOpen is provided as a quicker means to open a RAR archive if the intended usage is to simply call Unrar to extract the files and directories.

Returns TRUE for success, FALSE for failure.

HCkRarEntry CkRar_GetEntryByIndex(HCkRar cHandle, long index);

Returns a RarEntry object for the Nth entry in the RAR archive. The archive must have first been opened by calling Open (not FastOpen). Returns null if the index is out of range. The 1st entry is at index 0.

HCkRarEntry CkRar_GetEntryByName(HCkRar cHandle, const char *filename);

Returns a RarEntry object by filename. The RAR archive must have first been opened by calling Open (not FastOpen). Returns null if the entry was not found.

BOOL CkRar_Open(HCkRar cHandle, const char *filename);

Opens a RAR archive. The filename may include an absolute or relative directory path. This method iterates over the files and directories. Upon returning, the NumEntries property contains the number of files/directories in the RAR, and GetEntryByIndex may be called to retrieve information about each file/directory.

Returns TRUE for success, FALSE for failure.

BOOL CkRar_SaveLastError(HCkRar cHandle, const char *filename);

Saves the last error information to an XML formatted file.

BOOL CkRar_Unrar(HCkRar cHandle, const char *dirPath);

Extracts the files and directories from a RAR archive. The directory tree contained within the RAR is re-created with it's root at dirPath.

Returns TRUE for success, FALSE for failure.

const char *CkRar_lastErrorHtml(HCkRar cHandle);

Error information in HTML format for the last method called.

const char *CkRar_lastErrorText(HCkRar cHandle);

Error information in plain-text format for the last method called.

const char *CkRar_lastErrorXml(HCkRar cHandle);

Error information in XML format for the last method called.