forked from enlightenment/efl
parent
e9cb529e2d
commit
26ca180c07
|
@ -189,6 +189,23 @@ extern "C" {
|
|||
*/
|
||||
EAPI int eet_write (Eet_File *ef, char *name, void *data, int size, int compress);
|
||||
|
||||
/**
|
||||
* Delete a specified entry from an Eet file being written or re-written
|
||||
* @param ef A valid eet file handle opened for writing.
|
||||
* @param name Name of the entry. eg: "/base/file_i_want".
|
||||
* @return Success or failure of the delete.
|
||||
*
|
||||
* This function will delete the specified chunk of data from the eet file
|
||||
* and return greater than 0 on success. 0 will be returned on failure.
|
||||
*
|
||||
* The eet file handle must be a valid file handle for an eet file opened
|
||||
* for writing. If it is not, 0 will be returned and no action will be
|
||||
* performed.
|
||||
*
|
||||
* Name, must not be NULL, otherwise 0 will be returned.
|
||||
*/
|
||||
EAPI int eet_delete(Eet_File *ef, char *name);
|
||||
|
||||
/**
|
||||
* List all entries in eet file matching shell glob.
|
||||
* @param ef A valid eet file handle.
|
||||
|
|
|
@ -282,6 +282,8 @@ eet_flush(Eet_File *ef)
|
|||
int buf_size;
|
||||
int name_size;
|
||||
|
||||
if (ef->header->directory->hash[i].node[j].compression >= 0)
|
||||
{
|
||||
name_size = strlen(ef->header->directory->hash[i].node[j].name);
|
||||
buf_size = 20 + name_size;
|
||||
buf = malloc(buf_size);
|
||||
|
@ -311,6 +313,7 @@ eet_flush(Eet_File *ef)
|
|||
free(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* write data */
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
|
@ -914,6 +917,7 @@ eet_write(Eet_File *ef, char *name, void *data, int size, int compress)
|
|||
ef->header->directory->hash[hash].node[i].data_size = size;
|
||||
ef->header->directory->hash[hash].node[i].data = data2;
|
||||
exists_already = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -946,6 +950,51 @@ eet_write(Eet_File *ef, char *name, void *data, int size, int compress)
|
|||
return data_size;
|
||||
}
|
||||
|
||||
int
|
||||
eet_delete(Eet_File *ef, char *name)
|
||||
{
|
||||
int hash, node_size;
|
||||
Eet_File_Node *node;
|
||||
int exists_already = 0;
|
||||
|
||||
/* check to see its' an eet file pointer */
|
||||
if ((!ef) || (ef->magic != EET_MAGIC_FILE)
|
||||
|| (!name) ||
|
||||
((ef->mode != EET_FILE_MODE_WRITE) &&
|
||||
(ef->mode != EET_FILE_MODE_RW)))
|
||||
return 0;
|
||||
|
||||
if (!ef->header) return 0;
|
||||
|
||||
/* figure hash bucket */
|
||||
hash = eet_hash_gen(name, ef->header->directory->size);
|
||||
node_size = ef->header->directory->hash[hash].size;
|
||||
|
||||
/* Does this node already exist? */
|
||||
if (ef->mode == EET_FILE_MODE_RW)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < node_size; i++)
|
||||
{
|
||||
/* if it matches */
|
||||
if (eet_string_match(ef->header->directory->hash[hash].node[i].name, name))
|
||||
{
|
||||
free(ef->header->directory->hash[hash].node[i].data);
|
||||
ef->header->directory->hash[hash].node[i].compression = -1;
|
||||
ef->header->directory->hash[hash].node[i].size = 0;
|
||||
ef->header->directory->hash[hash].node[i].data_size = 0;
|
||||
ef->header->directory->hash[hash].node[i].data = NULL;
|
||||
exists_already = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* flags that writes are pending */
|
||||
if (exists_already) ef->writes_pending = 1;
|
||||
/* update access time */
|
||||
return exists_already;
|
||||
}
|
||||
|
||||
char **
|
||||
eet_list(Eet_File *ef, char *glob, int *count_ret)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue