Changeset 23 for trunk/lib/Directory.cc


Ignore:
Timestamp:
Jan 2, 2006, 9:14:57 AM (17 years ago)
Author:
Peter Johansson
Message:

added print functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r22 r23  
    66
    77#include <algorithm>
     8#include <fstream>
    89#include <iostream>
    910#include <iterator>
     
    7071
    7172
    72   void Directory::print(void) {
    73     // Jari, temporary using this to print directory tree
    74     for_each(daughters_.begin(),daughters_.end(), std::mem_fun(&Node::print));
     73  void Directory::print(const std::string& path) const
     74  {
     75    // Peter, creation of dir should be done without system call
     76    std::string system_call("mkdir " + path + name()+">& /dev/null");
     77    system(system_call.c_str());
     78    std::string output(path + name() + "/index.html");
     79    std::ofstream os(output.c_str());
     80    print_header(os);
     81    os << std::endl;
     82    stats_.print(os);
     83    os << std::endl;
     84
     85    for (NodeConstIter_ i=daughters_.begin();i!=daughters_.end();i++){
     86      (*i)->print_link(os);
     87      os << "<br/>" << std::endl;
     88    }
     89
     90    print_footer(os);
     91    os.close();
     92
     93    for (NodeConstIter_ i=daughters_.begin();i!=daughters_.end();i++)
     94      (*i)->print(path+name()+"/");
     95  }
     96
     97  void Directory::print_link(std::ostream& os) const
     98  {
     99    os << "<a href=\"" << name() << "/index.html\">" << name() << "</a>";
    75100  }
    76101
Note: See TracChangeset for help on using the changeset viewer.