directory_entry dereference() const noexcept { #if PLATFORM_KERNEL == PLATFORM_KERNEL_LINUX auto ent = (native_dirent*)m_buf_cur; // The type of the file is stored in the last byte of the // directory record. auto type = static_cast<file_type>(*(char*)(m_buf_cur + ent->d_reclen - 1)); // Compute the maximum length of the file name. auto max_len = length_type(ent->d_reclen - 2 - offsetof(detail::linux_dirent, d_name)); // The actual length of the file name could be less than what is // reported by the system call. So we have to find the null // character manually. auto start = &ent->d_name; auto end = std::find(start, start + max_len, '\0'); assert(end != start + max_len); return {*this, &ent->d_name, (uint16_t)(end - start), type}; #elif PLATFORM_KERNEL == PLATFORM_KERNEL_XNU auto ent = (native_dirent*)m_buf_cur; return {*this, ent->d_name, ent->d_namlen, static_cast<file_type>(ent->d_type)}; #endif }
int main() { testDivision(); length_type MAP_SIZE = length_type(64.f * 533.333f); Point center = {MAP_SIZE/2, MAP_SIZE/2}; QuadTree * tree = QuadTree::create(8, center, MAP_SIZE); if (!tree) return 0; tree->debugSelf(); Circle c = {MAP_SIZE/2, MAP_SIZE/2, 1}; TreeVisitor visitor = {tree}; AABox2d box(AABox2d::create(c)); tree->intersectRecursive(box, visitor); tree->intersect(box, visitor); QuadIterator it = tree->deepestContaining(AABox2d::create(c)); _getch(); return 0; }