Main Page | Modules | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

zipcache.c File Reference


Detailed Description

Zip Support for Java VM.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "hyport.h"
#include "zipsup.h"
#include "hypool.h"

Functions

HyZipCache * zipCache_new (HyPortLibrary *portLib, char *zipName, IDATA zipNameLength)
 Creates a new, empty zip cache for the provided zip file.
BOOLEAN zipCache_addElement (HyZipCache *zipCache, char *elementName, UDATA elementOffset)
 Add an association between a file or directory named elementName and offset elementOffset to the zip cache provided.
UDATA zipCache_findElement (HyZipCache *zipCache, const char *elementName, BOOLEAN searchDirList)
 Returns the offset associated with a file or directory element named elementName in a zipCache.
void zipCache_kill (HyZipCache *zipCache)
 Deletes a zip cache and frees its resources.
IDATA zipCache_enumNew (HyZipCache *zipCache, char *directoryName, void **handle)
 Searches for a directory named elementName in zipCache and if found provides a handle to it that can be used to enumerate through all of the directory's files.
IDATA zipCache_enumElement (void *handle, char *nameBuf, UDATA nameBufSize, UDATA *offset)
 Gets the name and offset of the next element in the directory being enumerated.
IDATA zipCache_enumGetDirName (void *handle, char *nameBuf, UDATA nameBufSize)
 Gets the name of the directory on which the enumeration is based.
void zipCache_enumKill (void *handle)
 Frees any resources allocated by zipCache_enumNew.


Function Documentation

BOOLEAN zipCache_addElement HyZipCache *  zipCache,
char *  elementName,
UDATA  elementOffset
 

Add an association between a file or directory named elementName and offset elementOffset to the zip cache provided.

Parameters:
[in] zipCache the zip cache being added to
[in] elementName the name of the file or directory element
[in] offset the corresponding offset of the element
Returns:
TRUE if the association was made, FALSE otherwise

IDATA zipCache_enumElement void *  handle,
char *  nameBuf,
UDATA  nameBufSize,
UDATA *  offset
 

Gets the name and offset of the next element in the directory being enumerated.

If nameBufSize is insufficient to hold the entire name, returns the required size for nameBuf.

Note:
Does NOT skip the element if nameBufSize buffer is of insufficient size to hold the entire name.
Parameters:
[in] handle returned from zipCache_enumNew. Used to enumerate the elements corresponding to the directory name returned by zipCache_enumGetDirName
[out] nameBuf holder for element in the directory being enumerated
[in] nameBufSize 
[out] offset the offset of the next element
Returns:
0 on success

-1 if all the directories have been returned already

the required size of nameBuf if nameBufSize is insuffient to hold the entire name (does not skip the element)

See also:
zipCache_enumNew

IDATA zipCache_enumGetDirName void *  handle,
char *  nameBuf,
UDATA  nameBufSize
 

Gets the name of the directory on which the enumeration is based.

Parameters:
[in] handle handle returned from zipCache_enumNew.
[out] nameBuf buffer to hold the directory name
[in] nameBufSize 
Returns:
0 on success

-3 on param failures

the required size for nameBuf if nameBufSize is insufficient to hold the entire name

void zipCache_enumKill void *  handle  ) 
 

Frees any resources allocated by zipCache_enumNew.

Parameters:
[in] handle enumerate on this handle
Returns:
none
See also:
zipCache_enumNew

IDATA zipCache_enumNew HyZipCache *  zipCache,
char *  directoryName,
void **  handle
 

Searches for a directory named elementName in zipCache and if found provides a handle to it that can be used to enumerate through all of the directory's files.

Note:
The search is CASE-INSENSITIVE (contrast with zipCache_findElement, which is case-sensitive).

The search is NOT recursive.

Parameters:
[in] zipCache the zip cache that is being searched
[in] directoryName the directory we want to enumerate
[out] handle enumerate all the files in directory directoryName on this handle
Returns:
0 on success and sets handle

-1 if the directory is not found

-2 if there is not enough memory to complete this call

See also:
zipCache_findElement

UDATA zipCache_findElement HyZipCache *  zipCache,
const char *  elementName,
BOOLEAN  searchDirList
 

Returns the offset associated with a file or directory element named elementName in a zipCache.

Parameters:
[in] zipCache the zip cache we are searching
[in] elementName the name of the element of which we want the offset
[in] searchDirList when TRUE, search the dir list even if elementName does not end in '/'
Returns:
the zipCache if a match is found

-1 if no element of that name has been explicitly added to the cache.

void zipCache_kill HyZipCache *  zipCache  ) 
 

Deletes a zip cache and frees its resources.

Parameters:
[in] zipCache the zip cache to be freed
Returns:
none
See also:
zipCache_new

HyZipCache* zipCache_new HyPortLibrary portLib,
char *  zipName,
IDATA  zipNameLength
 

Creates a new, empty zip cache for the provided zip file.

Parameters:
[in] portLib the port library
[in] zipName the zip file name
[in] zipNameLength 
Returns:
the new zip cache if one was succesfully created, NULL otherwise


(c) Copyright 2005 The Apache Software Foundation or its licensors, as applicable.