+eet_alias_get, related, docs, some spelling corrections

SVN revision: 61915
This commit is contained in:
Mike Blumenkrantz 2011-07-30 01:31:40 +00:00
parent 7542b592c0
commit 80a1aea7b0
3 changed files with 99 additions and 2 deletions

View File

@ -522,3 +522,7 @@
* On Windows, open() in text mode followed by fdopen() in
binary mode does not create a stream in binary mode.
So add O_BINARY to open().
2011-07-29 Mike Blumenkrantz
* Add eet_alias_get to return the destination name of an alias

View File

@ -20,6 +20,7 @@ These routines are used for Eet Library interaction
@author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
@author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
@author Adam Simpkins <adam@@adamsimpkins.net>
@author Mike Blumenkrantz <mike@zentific.com>
@date 2000-2011
@section toc Table of Contents
@ -750,11 +751,11 @@ eet_delete(Eet_File *ef,
* no check are done.
* @param ef A valid eet file handle opened for writing.
* @param name Name of the entry. eg: "/base/file_i_want".
* @param destination Destionation of the alias. eg: "/base/the_real_stuff_i_want".
* @param destination Destination of the alias. eg: "/base/the_real_stuff_i_want".
* @param compress Compression flags (1 == compress, 0 = don't compress).
* @return EINA_TRUE on success, EINA_FALSE on failure.
*
* Name and Destination must not be NULL, otherwhise EINA_FALSE will be returned.
* Name and Destination must not be NULL, otherwise EINA_FALSE will be returned.
*
* @since 1.3.3
* @ingroup Eet_File_Group
@ -765,6 +766,21 @@ eet_alias(Eet_File *ef,
const char *destination,
int compress);
/**
* Retrieve the destination name of an alias
* @param ef A valid eet file handle opened for writing
* @param name Name of the entry. eg: "/base/file_i_want"
* @return Destination of the alias. eg: "/base/the_real_stuff_i_want", NULL on failure
*
* Name must not be NULL, otherwise NULL will be returned.
*
* @since 1.5
* @ingroup Eet_File_Group
*/
EAPI const char *
eet_alias_get(Eet_File *ef,
const char *name);
/**
* List all entries in eet file matching shell glob.
* @param ef A valid eet file handle.

View File

@ -1983,6 +1983,83 @@ on_error:
return NULL;
} /* eet_read_direct */
EAPI const char *
eet_alias_get(Eet_File *ef,
const char *name)
{
Eet_File_Node *efn;
const char *data = NULL;
int size = 0;
/* check to see its' an eet file pointer */
if (eet_check_pointer(ef))
return NULL;
if (!name)
return NULL;
if ((ef->mode != EET_FILE_MODE_READ) &&
(ef->mode != EET_FILE_MODE_READ_WRITE))
return NULL;
/* no header, return NULL */
if (eet_check_header(ef))
return NULL;
LOCK_FILE(ef);
/* hunt hash bucket */
efn = find_node_by_name(ef, name);
if (!efn)
goto on_error;
/* trick to detect data in memory instead of mmaped from disk */
if (efn->offset > ef->data_size && !efn->data)
goto on_error;
/* get size (uncompressed, if compressed at all) */
size = efn->data_size;
if (!efn->alias) return NULL;
data = efn->data ? efn->data : ef->data + efn->offset;
/* handle alias case */
if (efn->compression)
{
char *tmp;
int compr_size = efn->size;
uLongf dlen;
tmp = alloca(sizeof (compr_size));
dlen = size;
if (uncompress((Bytef *)tmp, &dlen, (Bytef *)data,
(uLongf)compr_size))
goto on_error;
if (tmp[compr_size - 1] != '\0')
goto on_error;
UNLOCK_FILE(ef);
return eina_stringshare_add(tmp);
}
if (!data)
goto on_error;
if (data[size - 1] != '\0')
goto on_error;
UNLOCK_FILE(ef);
return eina_stringshare_add(data);
on_error:
UNLOCK_FILE(ef);
return NULL;
}
EAPI Eina_Bool
eet_alias(Eet_File *ef,
const char *name,