#pypp 0 // Iris: micro-kernel for a capability-based operating system. // source/test.ccp: Testing program. // Copyright 2009 Bas Wijnen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include #include bool match (char const *a, char const *b, unsigned l1, unsigned l2): if l1 != l2: return false for unsigned i = 0; i < l1; ++i: if a[i] != b[i]: return false return true static bool print_name (Iris::String name, unsigned indent): unsigned l = name.get_size ().l for unsigned i = 0; i < indent; ++i: kdebug_char (' ') char part[16] for unsigned i = 0; i < l; i += 16: name.get_chars (i, part) for unsigned k = 0; k < 16 && i * 16 + k < l; ++k: kdebug_char (part[k]) kdebug_char ('\n') return match (part, ".", l, 1) || match (part, "..", l, 2) static void print_dir (Iris::Directory dir, unsigned indent): dir.lock_ro () Iris::Num files = dir.get_size () for Iris::Num i = 0; i.value () < files.value (); i = i.value () + 1: Iris::String f = dir.get_name (i) bool ignore = print_name (f, indent) if !ignore && dir.get_file_info (i, 0).l & 1: Iris::Directory d = dir.get_file_ro (i) print_dir (d, indent + 4) Iris::free_cap (d) Iris::free_cap (f) dir.unlock_ro () Iris::Num start (): Iris::Directory dir = Iris::my_parent.get_capability () print_dir (dir, 0) return 0