forked from enlightenment/efl
parent
91a435fd4f
commit
97b8f7a58d
|
@ -631,132 +631,6 @@ eet_flush2(Eet_File *ef)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* Unused */
|
|
||||||
/* flush out writes to an eet file */
|
|
||||||
static Eet_Error
|
|
||||||
eet_flush(Eet_File *ef)
|
|
||||||
{
|
|
||||||
Eet_File_Node *efn;
|
|
||||||
int head[3];
|
|
||||||
int count = 0;
|
|
||||||
int size = 0;
|
|
||||||
int offset = 0;
|
|
||||||
int i;
|
|
||||||
int num;
|
|
||||||
|
|
||||||
/* check to see its' an eet file pointer */
|
|
||||||
if (eet_check_pointer(ef))
|
|
||||||
return EET_ERROR_BAD_OBJECT;
|
|
||||||
if (eet_check_header(ef))
|
|
||||||
return EET_ERROR_EMPTY;
|
|
||||||
if ((ef->mode != EET_FILE_MODE_WRITE) && (ef->mode != EET_FILE_MODE_READ_WRITE))
|
|
||||||
return EET_ERROR_NOT_WRITABLE;
|
|
||||||
if (!ef->writes_pending)
|
|
||||||
return EET_ERROR_NONE;
|
|
||||||
|
|
||||||
/* calculate total size in bytes of directory block */
|
|
||||||
num = (1 << ef->header->directory->size);
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
|
|
||||||
{
|
|
||||||
size += 20 + strlen(efn->name) + 1;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* calculate offsets per entry */
|
|
||||||
offset = 0;
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
|
|
||||||
{
|
|
||||||
efn->offset = 12 + size + offset;
|
|
||||||
offset += efn->size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* go thru and write the header */
|
|
||||||
head[0] = (int) htonl ((unsigned int) EET_MAGIC_FILE);
|
|
||||||
head[1] = (int) htonl ((unsigned int) count);
|
|
||||||
head[2] = (int) htonl ((unsigned int) size);
|
|
||||||
|
|
||||||
fseek(ef->fp, 0, SEEK_SET);
|
|
||||||
if (fwrite(head, 12, 1, ef->fp) != 1)
|
|
||||||
goto write_error;
|
|
||||||
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
|
|
||||||
{
|
|
||||||
unsigned int ibuf[5];
|
|
||||||
int name_size;
|
|
||||||
|
|
||||||
name_size = strlen(efn->name) + 1;
|
|
||||||
|
|
||||||
ibuf[0] = (int) htonl ((unsigned int) efn->offset);
|
|
||||||
ibuf[1] = (int) htonl ((unsigned int) efn->compression);
|
|
||||||
ibuf[2] = (int) htonl ((unsigned int) efn->size);
|
|
||||||
ibuf[3] = (int) htonl ((unsigned int) efn->data_size);
|
|
||||||
ibuf[4] = (int) htonl ((unsigned int) name_size);
|
|
||||||
|
|
||||||
|
|
||||||
if (fwrite(ibuf, sizeof(ibuf), 1, ef->fp) != 1)
|
|
||||||
goto write_error;
|
|
||||||
if (fwrite(efn->name, name_size, 1, ef->fp) != 1)
|
|
||||||
goto write_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write data */
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
|
|
||||||
{
|
|
||||||
if (fwrite(efn->data, efn->size, 1, ef->fp) != 1)
|
|
||||||
goto write_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* no more writes pending */
|
|
||||||
ef->writes_pending = 0;
|
|
||||||
|
|
||||||
return EET_ERROR_NONE;
|
|
||||||
|
|
||||||
write_error:
|
|
||||||
if (ferror(ef->fp))
|
|
||||||
{
|
|
||||||
switch (errno)
|
|
||||||
{
|
|
||||||
case EFBIG:
|
|
||||||
fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR_FILE_TOO_BIG;
|
|
||||||
case EIO:
|
|
||||||
fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR_IO_ERROR;
|
|
||||||
case ENOSPC:
|
|
||||||
fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR_OUT_OF_SPACE;
|
|
||||||
case EPIPE:
|
|
||||||
fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR_FILE_CLOSED;
|
|
||||||
default:
|
|
||||||
fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sign_error:
|
|
||||||
if (ef->fp) fclose(ef->fp);
|
|
||||||
ef->fp = NULL;
|
|
||||||
return EET_ERROR_WRITE_ERROR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
eet_init(void)
|
eet_init(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue