std::vector<libtocc::FileInfo> FSHandler::query_by_path(std::string path) { // We assume that each element of the path is a tag, and return // everything matches with it. std::vector<std::string> path_items = split_string(path, '/'); // The previous step didn't find the correct result. Now, assuming // that all the elements in path are tags. std::vector<std::string>::iterator path_items_iterator = path_items.begin(); // Adding first element to the And. libtocc::Tag first_tag(path_items_iterator->c_str()); libtocc::And third_main_and(first_tag); path_items_iterator++; for (; path_items_iterator != path_items.end(); path_items_iterator++) { if (*path_items_iterator == ".." || *path_items_iterator == ".") { // Ignore . or .. continue; } libtocc::Tag tag_expr(path_items_iterator->c_str()); third_main_and.add(tag_expr); } // Executing the query. libtocc::Query third_query(third_main_and); libtocc::FileInfoCollection third_query_result = this->libtocc_manager->search_files(third_query); if (third_query_result.size() > 0) { std::vector<libtocc::FileInfo> result; libtocc::FileInfoCollection::Iterator query_result_iterator(&third_query_result); for (; !query_result_iterator.is_finished(); query_result_iterator.next()) { result.push_back(*query_result_iterator.get()); } return result; } // Nothing found? Returning an empty result. std::vector<libtocc::FileInfo> result; return result; }
void insert_new_tag2(GapIO *io, int into, int *cache, int cache_len, int *cache_pos, int pos, int length, char *type, char *comment, int sense) { tag_id prev, next, newt; tagRecord prev_tag, next_tag, new_tag; int i; /* Initialise cache if required */ if (pos >= *cache_pos) { next = cache[*cache_pos]; if (!next) next = first_tag(io, into); while (next) { read_tag(io, next, &next_tag); if (next_tag.position < *cache_pos) { next = next_tag.next; continue; } if (next_tag.position > pos) break; for (i = *cache_pos; i < next_tag.position; i++) cache[i] = cache[*cache_pos]; for (; i <= next_tag.position; i++) { cache[i] = next; } *cache_pos = i-1; next = next_tag.next; } for (i = *cache_pos+1; i <= pos; i++) cache[i] = cache[*cache_pos]; *cache_pos = pos; } /* Find previous and next tags - quick lookup in cache */ prev = cache[pos]; if (!prev) { next = first_tag(io, into); } else { read_tag(io, prev, &prev_tag); next = prev_tag.next; } /* Create and initialise new tag */ newt = get_free_tag(io); new_tag.position = pos; new_tag.length = length; strncpy(new_tag.type.c,type,4); if (comment!=NULL) new_tag.comment = put_comment(io, comment); else new_tag.comment = 0; new_tag.next = next; new_tag.sense = sense; write_tag(io, newt, new_tag); /* Update cache */ i = pos; while (i <= *cache_pos && cache[i] == prev) cache[i++] = newt; if (pos > *cache_pos) { int j, k = cache[*cache_pos]; for (j = *cache_pos; j < pos; j++) cache[j] = k; cache[pos] = newt; *cache_pos = pos; } /* Link previous tag */ if (prev) { prev_tag.next = newt; write_tag(io, prev, prev_tag); } else { update_tag(io, into, newt); } }
update_tag(io, into, newt); } } void insert_NEW_tag(GapIO *io, int N, int pos, int length, char *type, char *comment, int sense) /* * :-) */ { tag_id last,next,new; tagRecord last_tag,next_tag,new_tag; last = 0; /* indicated start of linked list */ next = first_tag(io, N); /* * Find position to insert */ while (next) { read_tag(io, next,&next_tag); if (next_tag.position > pos) break; last_tag = next_tag; last = next; next = next_tag.next; } /* * create and initialise new tag