Ejemplo n.º 1
0
static Vector*
S_find_all_referenced(Folder *folder, Vector *entries) {
    Hash *uniqued = Hash_new(Vec_Get_Size(entries));
    for (uint32_t i = 0, max = Vec_Get_Size(entries); i < max; i++) {
        String *entry = (String*)Vec_Fetch(entries, i);
        Hash_Store(uniqued, entry, (Obj*)CFISH_TRUE);
        if (Folder_Is_Directory(folder, entry)) {
            Vector *contents = Folder_List_R(folder, entry);
            for (uint32_t j = Vec_Get_Size(contents); j--;) {
                String *sub_entry = (String*)Vec_Fetch(contents, j);
                Hash_Store(uniqued, sub_entry, (Obj*)CFISH_TRUE);
            }
            DECREF(contents);
        }
    }
    Vector *referenced = Hash_Keys(uniqued);
    DECREF(uniqued);
    return referenced;
}
Ejemplo n.º 2
0
static VArray*
S_find_all_referenced(Folder *folder, VArray *entries)
{
    Hash *uniqued = Hash_new(VA_Get_Size(entries));
    for (uint32_t i = 0, max = VA_Get_Size(entries); i < max; i++) {
        CharBuf *entry = (CharBuf*)VA_Fetch(entries, i);
        Hash_Store(uniqued, (Obj*)entry, INCREF(&EMPTY));
        if (Folder_Is_Directory(folder, entry)) {
            VArray *contents = Folder_List_R(folder, entry);
            for (uint32_t j = VA_Get_Size(contents); j--; ) {
                CharBuf *sub_entry = (CharBuf*)VA_Fetch(contents, j);
                Hash_Store(uniqued, (Obj*)sub_entry, INCREF(&EMPTY));
            }
            DECREF(contents);
        }
    }
    VArray *referenced = Hash_Keys(uniqued);
    DECREF(uniqued);
    return referenced;
}