Add no-deprecated to warnings due to dynamic exceptions.
[anna.git] / example / dbos / workdir / filesystem / Directory.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <iostream>
10
11 #include "Directory.hpp"
12 #include "File.hpp"
13
14 using namespace std;
15 using namespace anna;
16 using namespace workdir;
17
18 void filesystem::Directory::print (const int level) const
19    throw ()
20 {
21    filesystem::Directory::const_child_iterator ii;
22    filesystem::Directory::const_child_iterator maxii = child_end ();
23    const filesystem::Directory* auxd;
24    const filesystem::File* auxf; 
25    int row = 0;
26    bool hasDirectories = false;
27
28    for (int space = 0; space < level; space ++)
29       cout << "   ";
30
31    cout << getName () << "/ (" << child_size () << "): " << endl;
32    
33    /* 
34     * Recorre todas las dependencias y visualiza primero todos los ficheros
35     */
36    for (ii = child_begin (); ii != maxii; ii ++) {
37       auxf = filesystem::File::down_cast (filesystem::Directory::child (ii));
38       
39       if (auxf == NULL) {
40          hasDirectories = true;
41          continue;
42       }
43       
44       if (row == 0) {
45          for (int space = 0; space < level +  1; space ++)
46             cout << "   ";
47       }
48       
49       auxf->print (level + 1);
50       
51       if (++ row == 5) {
52          cout << endl;
53          row = 0;
54       }
55    }
56
57    if (row > 0)
58       cout << endl;
59    
60    /* 
61     * Trata los directorios recursivamente
62     */
63    for (ii = child_begin (); hasDirectories == true && ii != maxii; ii ++) {
64       auxd = filesystem::Directory::down_cast (filesystem::Directory::child (ii));
65       
66       if (auxd != NULL)
67          auxd->print (level + 1);
68    }      
69 }