Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "nstream/nstream.h"
00012
00013 #include <iostream>
00014
00015 #include "common/wave_ex.h"
00016 #include "perf/perf.h"
00017
00018
00019
00020 static void * const s_magic = (void * const) 0x5488943a;
00021
00022
00023
00024
00025
00026
00027
00028
00029 static nstream::eIterationFlag
00030 displayEntry
00031 (
00032 IN nstream::Entry * entry,
00033 IN void * context
00034 )
00035 {
00036 ASSERT(entry, "null");
00037 ASSERT(s_magic == context, "context mismatch?");
00038
00039 DPRINTF(" Entry: %s", entry->getName());
00040
00041 return nstream::eIterate_Continue;
00042 }
00043
00044
00045
00046 static void
00047 doTest
00048 (
00049 IN const char * dir
00050 )
00051 {
00052 ASSERT(dir, "null");
00053
00054 smart_ptr<nstream::Manager> mgr = nstream::getFilesystemManager(dir);
00055 THROW(mgr, "failed to get manager for directory: " << dir);
00056
00057 smart_ptr<nstream::Folder> root = mgr->getRoot();
00058 THROW(root, "failed to get root folder");
00059
00060 DPRINTF("Iterating root for directory: %s", dir);
00061 smart_ptr<nstream::Entry> entry;
00062 while (entry = root->getNextChild()) {
00063 DPRINTF(" Entry: %s", entry->getName());
00064 switch (entry->getType()) {
00065 case nstream::Entry::eType_Folder:
00066 DPRINTF(" Folder!");
00067 break;
00068
00069 case nstream::Entry::eType_File:
00070 DPRINTF(" File!");
00071 break;
00072
00073 default:
00074 {
00075 WAVE_EX(wex);
00076 wex << "Unknown type! path: ";
00077 wex << entry->getName();
00078 }
00079 }
00080 }
00081
00082
00083 DPRINTF("Recursive walk of '%s':", dir);
00084 nstream::walkChildFolders(root, displayEntry, s_magic);
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 int
00096 main
00097 (
00098 IN int argc,
00099 IN const char * argv[]
00100 )
00101 {
00102 ASSERT(2 == argc, "Usage: nstream-test <directory>");
00103 const char * dir = argv[1];
00104
00105 try {
00106 perf::Timer timer("overall timer");
00107 doTest(dir);
00108 } catch (std::exception& e) {
00109 DPRINTF("Exception! %s", e.what());
00110 return 1;
00111 }
00112
00113
00114 perf::dumpTimingSummary(std::cout);
00115 return 0;
00116 }
00117