Esempio n. 1
0
void IndexCategories(Category *head[], const char *path, int location)
{
    SceIoDirent dir;
    SceUID fd;
    u64 mtime;
    char full_path[16];
    int match;

    sce_paf_private_strcpy(full_path, path);
    SET_DEVICENAME(full_path, location);

    if((fd = sceIoDopen(full_path)) < 0) {
        return;
    }

    kprintf("Indexing categories from %s, loc: %i\n", path, location);
    match = 0;
    sce_paf_private_memset(&dir, 0, sizeof(SceIoDirent));

    while(1) {
        if(sceIoDread(fd, &dir) <= 0) {
            kprintf("End of directory list\n");
            sceIoDclose(fd);
            break;
        }
        kprintf("checking [%s], length: %i\n", dir.d_name, sce_paf_private_strlen(dir.d_name));
        if (FIO_S_ISDIR(dir.d_stat.st_mode) && dir.d_name[0] != '.') {
            if(!config.prefix && !is_game_folder(full_path, dir.d_name)) {
                if(has_directories(full_path, dir.d_name) > 0) {
                    match = 1;
                }
            } else if(config.prefix && sce_paf_private_strncmp(dir.d_name, "CAT_", 4) == 0) {
                if(has_directories(full_path, dir.d_name) > 0) {
                    sce_paf_private_strcpy(dir.d_name, dir.d_name + 4);
                    match = 1;
                }
            }
            if(match) {
                match = 0;
                sceRtcGetTick((pspTime *) &dir.d_stat.st_mtime, &mtime);
                kprintf("Adding category: [%s]\n", dir.d_name);
                AddCategory(head, dir.d_name, mtime, location);
            }
        }
    }
}
Esempio n. 2
0
int AddCategory(Category *head[], const char *category, u64 mtime, int location)
{
    Category *p, *category_entry;

    while (1) {
        p = NULL;
        while ((p = GetNextCategory(head, p, location))) {
            if (sce_paf_private_strcmp(category, &p->name) == 0) {
                return 0;
            }
            if (p->mtime == mtime) {
                mtime++;
                break;
            }
        }
        if (!p) {
            break;
        }
    }
    kprintf("Adding [%s]\n", category);
    category_entry = (Category *) sce_paf_private_malloc(sizeof(Category) + sce_paf_private_strlen(category) + 1);
    if (category_entry) {
        category_entry->next = NULL;
        category_entry->mtime = mtime;
        category_entry->location = location;
        sce_paf_private_strcpy(&category_entry->name, category);

        if (!head[location]) {
            head[location] = category_entry;
        } else {
            p = (Category *) head[location];
            while (p->next) {
                p = p->next;
            }
            p->next = category_entry;
        }
        return 1;
    }
    return 0;
}
Esempio n. 3
0
File: mode.c Progetto: kimus/gclite
/* Functions */
int CategorizeGamePatched(void *unk, int folder, int unk2) {
    int i;
    u32 *array = (u32 *) *(u32 *) ((*(u32 *) (text_addr_game + patches.struct_addr[patch_index])) + ((u32) folder << 2));
    char *title = (char *) array[68 / 4];
    kprintf("called\n");
    Category *p = GetNextCategory(folder_list, NULL, global_pos);

    for (i = patches.index[patch_index]; p; i++) {
        char *name = &p->name;
        kprintf("name: %s\n", name);
        int len = sce_paf_private_strlen(name);

        if (sce_paf_private_strncmp(name, title, len) == 0) {
            if (title[len] == '/') {
                return CategorizeGame(unk, i, unk2);
            }
        }

        p = GetNextCategory(folder_list, p, 0);
    }

    /* uncategorized */
    return CategorizeGame(unk, i - 1, unk2);
}