Пример #1
0
static void *HHA_openArchive(const char *name, int forWriting)
{
    PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
    HHAinfo *info = (HHAinfo *) allocator.Malloc(sizeof (HHAinfo));

    BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);

    memset(info, '\0', sizeof (HHAinfo));
    info->filename = (char *) allocator.Malloc(strlen(name) + 1);
    GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, HHA_openArchive_failed);

    if (!HHA_load_entries(name, forWriting, info))
        goto HHA_openArchive_failed;

    strcpy(info->filename, name);
    info->last_mod_time = modtime;

    return(info);

HHA_openArchive_failed:
    if (info != NULL)
    {
        if (info->filename != NULL)
            allocator.Free(info->filename);
        if (info->entries != NULL)
            allocator.Free(info->entries);
        allocator.Free(info);
    } /* if */

    return(NULL);
} /* HHA_openArchive */
Пример #2
0
Файл: dir.c Проект: leonlee/tome
static PHYSFS_sint64 DIR_getLastModTime(dvoid *opaque,
                                        const char *name,
                                        int *fileExists)
{
    char *d = __PHYSFS_platformCvtToDependent((char *) opaque, name, NULL);
    PHYSFS_sint64 retval = -1;

    BAIL_IF_MACRO(d == NULL, NULL, 0);
    *fileExists = __PHYSFS_platformExists(d);
    if (*fileExists)
        retval = __PHYSFS_platformGetLastModTime(d);
    allocator.Free(d);
    return(retval);
} /* DIR_getLastModTime */
Пример #3
0
static PHYSFS_sint64 DIR_getLastModTime(DirHandle *h,
                                        const char *name,
                                        int *fileExists)
{
    char *d = __PHYSFS_platformCvtToDependent((char *)(h->opaque), name, NULL);
    PHYSFS_sint64 retval = -1;

    BAIL_IF_MACRO(d == NULL, NULL, 0);
    *fileExists = __PHYSFS_platformExists(d);
    if (*fileExists)
        retval = __PHYSFS_platformGetLastModTime(d);
    free(d);
    return(retval);
} /* DIR_getLastModTime */
Пример #4
0
static DirHandle *HOG_openArchive(const char *name, int forWriting)
{
    HOGinfo *info;
    DirHandle *retval = malloc(sizeof (DirHandle));
    PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);

    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    info = retval->opaque = malloc(sizeof (HOGinfo));
    if (info == NULL)
    {
        __PHYSFS_setError(ERR_OUT_OF_MEMORY);
        goto HOG_openArchive_failed;
    } /* if */

    memset(info, '\0', sizeof (HOGinfo));

    info->filename = (char *) malloc(strlen(name) + 1);
    if (info->filename == NULL)
    {
        __PHYSFS_setError(ERR_OUT_OF_MEMORY);
        goto HOG_openArchive_failed;
    } /* if */

    if (!hog_load_entries(name, forWriting, info))
        goto HOG_openArchive_failed;

    strcpy(info->filename, name);
    info->last_mod_time = modtime;
    retval->funcs = &__PHYSFS_DirFunctions_HOG;
    return(retval);

HOG_openArchive_failed:
    if (retval != NULL)
    {
        if (retval->opaque != NULL)
        {
            if (info->filename != NULL)
                free(info->filename);
            if (info->entries != NULL)
                free(info->entries);
            free(info);
        } /* if */
        free(retval);
    } /* if */

    return(NULL);
} /* HOG_openArchive */