X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdbos%2Fworkdir%2Ffilesystem%2FDirectory.cpp;fp=example%2Fdbos%2Fworkdir%2Ffilesystem%2FDirectory.cpp;h=e22c859e5ae1a90d9177a0638c1eecd2006597d7;hb=78be86969d2f26a9084b0c4af6ce43d5fa4ed3fd;hp=0000000000000000000000000000000000000000;hpb=a3b95648bd76140ef55e0b5941d423eee6c3856f;p=anna.git diff --git a/example/dbos/workdir/filesystem/Directory.cpp b/example/dbos/workdir/filesystem/Directory.cpp new file mode 100644 index 0000000..e22c859 --- /dev/null +++ b/example/dbos/workdir/filesystem/Directory.cpp @@ -0,0 +1,69 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +#include + +#include "Directory.hpp" +#include "File.hpp" + +using namespace std; +using namespace anna; +using namespace workdir; + +void filesystem::Directory::print (const int level) const + throw () +{ + filesystem::Directory::const_child_iterator ii; + filesystem::Directory::const_child_iterator maxii = child_end (); + const filesystem::Directory* auxd; + const filesystem::File* auxf; + int row = 0; + bool hasDirectories = false; + + for (int space = 0; space < level; space ++) + cout << " "; + + cout << getName () << "/ (" << child_size () << "): " << endl; + + /* + * Recorre todas las dependencias y visualiza primero todos los ficheros + */ + for (ii = child_begin (); ii != maxii; ii ++) { + auxf = filesystem::File::down_cast (filesystem::Directory::child (ii)); + + if (auxf == NULL) { + hasDirectories = true; + continue; + } + + if (row == 0) { + for (int space = 0; space < level + 1; space ++) + cout << " "; + } + + auxf->print (level + 1); + + if (++ row == 5) { + cout << endl; + row = 0; + } + } + + if (row > 0) + cout << endl; + + /* + * Trata los directorios recursivamente + */ + for (ii = child_begin (); hasDirectories == true && ii != maxii; ii ++) { + auxd = filesystem::Directory::down_cast (filesystem::Directory::child (ii)); + + if (auxd != NULL) + auxd->print (level + 1); + } +}