added eet_num_entries()

SVN revision: 15785
This commit is contained in:
tsauerbeck 2005-07-15 20:37:29 +00:00 committed by tsauerbeck
parent 63c5d7586c
commit 216c51ea31
2 changed files with 36 additions and 0 deletions

View File

@ -243,6 +243,14 @@ extern "C" {
*/
EAPI char **eet_list (Eet_File *ef, char *glob, int *count_ret);
/**
* Return the number of entries in the specified eet file.
* @param ef A valid eet file handle.
* @return Number of entries in ef or -1 if the number of entries
* cannot be read due to open mode restrictions.
*/
EAPI int eet_num_entries(Eet_File *ef);
/***************************************************************************/
/**

View File

@ -1040,6 +1040,34 @@ eet_list(Eet_File *ef, char *glob, int *count_ret)
return list_ret;
}
int
eet_num_entries(Eet_File *ef)
{
int i, num, ret = 0;
Eet_File_Node *efn;
/* check to see its' an eet file pointer */
if ((!ef) || (ef->magic != EET_MAGIC_FILE) ||
(!ef->header) || (!ef->header->directory) ||
((ef->mode != EET_FILE_MODE_READ) &&
(ef->mode != EET_FILE_MODE_READ_WRITE)))
{
return -1;
}
/* loop through all entries */
num = (1 << ef->header->directory->size);
for (i = 0; i < num; i++)
{
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
{
ret++;
}
}
return ret;
}
int eet_init(void)
{
return ++eet_initcount;