Example #1
0
File: os2.c Project: UIKit0/paragui
int __PHYSFS_platformEOF(void *opaque)
{
    PHYSFS_sint64 len, pos;

    len = __PHYSFS_platformFileLength(opaque);
    BAIL_IF_MACRO(len == -1, NULL, 1);  /* (*shrug*) */
    pos = __PHYSFS_platformTell(opaque);
    BAIL_IF_MACRO(pos == -1, NULL, 1);  /* (*shrug*) */

    return(pos >= len);
} /* __PHYSFS_platformEOF */
Example #2
0
int __PHYSFS_platformEOF(void *opaque)
{
    PHYSFS_sint64 FilePosition;
    int retval = 0;

    /* Get the current position in the file */
    if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
    {
        /* Non-zero if EOF is equal to the file length */
        retval = FilePosition == __PHYSFS_platformFileLength(opaque);
    } /* if */

    return(retval);
} /* __PHYSFS_platformEOF */
Example #3
0
int __PHYSFS_platformEOF(void *opaque)
{
	const PHYSFS_sint64 FileLength = __PHYSFS_platformFileLength(opaque);
	PHYSFS_sint64 FilePosition;
	int retval = 0;

	if (FileLength == 0)
		return 1;  /* we're definitely at EOF. */

				   /* Get the current position in the file */
	if ((FilePosition = __PHYSFS_platformTell(opaque)) != -1)
	{
		/* Non-zero if EOF is equal to the file length */
		retval = (FilePosition == FileLength);
	} /* if */

	return(retval);
} /* __PHYSFS_platformEOF */
Example #4
0
File: posix.c Project: jcubic/ToME
int __PHYSFS_platformEOF(void *opaque)
{
    PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
    PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
    return(pos >= len);
} /* __PHYSFS_platformEOF */
Example #5
0
static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
{
    PHYSFS_uint8 buf[256];
    PHYSFS_sint32 i = 0;
    PHYSFS_sint64 filelen;
    PHYSFS_sint64 filepos;
    PHYSFS_sint32 maxread;
    PHYSFS_sint32 totalread = 0;
    int found = 0;
    PHYSFS_uint32 extra = 0;

    filelen = __PHYSFS_platformFileLength(in);
    BAIL_IF_MACRO(filelen == -1, NULL, 0);  /* !!! FIXME: unlocalized string */
    BAIL_IF_MACRO(filelen > 0xFFFFFFFF, "ZIP bigger than 2 gigs?!", 0);

    /*
     * Jump to the end of the file and start reading backwards.
     *  The last thing in the file is the zipfile comment, which is variable
     *  length, and the field that specifies its size is before it in the
     *  file (argh!)...this means that we need to scan backwards until we
     *  hit the end-of-central-dir signature. We can then sanity check that
     *  the comment was as big as it should be to make sure we're in the
     *  right place. The comment length field is 16 bits, so we can stop
     *  searching for that signature after a little more than 64k at most,
     *  and call it a corrupted zipfile.
     */

    if (sizeof (buf) < filelen)
    {
        filepos = filelen - sizeof (buf);
        maxread = sizeof (buf);
    } /* if */
    else
    {
        filepos = 0;
        maxread = (PHYSFS_uint32) filelen;
    } /* else */

    while ((totalread < filelen) && (totalread < 65557))
    {
        BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, filepos), NULL, -1);

        /* make sure we catch a signature between buffers. */
        if (totalread != 0)
        {
            if (__PHYSFS_platformRead(in, buf, maxread - 4, 1) != 1)
                return(-1);
            *((PHYSFS_uint32 *) (&buf[maxread - 4])) = extra;
            totalread += maxread - 4;
        } /* if */
        else
        {
            if (__PHYSFS_platformRead(in, buf, maxread, 1) != 1)
                return(-1);
            totalread += maxread;
        } /* else */

        extra = *((PHYSFS_uint32 *) (&buf[0]));

        for (i = maxread - 4; i > 0; i--)
        {
            if ((buf[i + 0] == 0x50) &&
                (buf[i + 1] == 0x4B) &&
                (buf[i + 2] == 0x05) &&
                (buf[i + 3] == 0x06) )
            {
                found = 1;  /* that's the signature! */
                break;  
            } /* if */
        } /* for */

        if (found)
            break;

        filepos -= (maxread - 4);
    } /* while */

    BAIL_IF_MACRO(!found, ERR_NOT_AN_ARCHIVE, -1);

    if (len != NULL)
        *len = filelen;

    return(filepos + i);
} /* zip_find_end_of_central_dir */
Example #6
0
File: dir.c Project: leonlee/tome
static PHYSFS_sint64 DIR_fileLength(fvoid *opaque)
{
    return(__PHYSFS_platformFileLength(opaque));
} /* DIR_fileLength */
Example #7
0
File: dir.c Project: UIKit0/paragui
static PHYSFS_sint64 DIR_fileLength(FileHandle *handle)
{
    return(__PHYSFS_platformFileLength(handle->opaque));
} /* DIR_fileLength */