Changeset 29


Ignore:
Timestamp:
Jan 9, 2006, 10:35:50 AM (16 years ago)
Author:
Peter Johansson
Message:

modified output file names

Location:
trunk/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r23 r29  
    1818namespace svnstat{
    1919
    20   Directory::Directory(const std::string& path)
    21     : Node(path)
     20  Directory::Directory(const std::string& path, const std::string& output)
     21    : Node(path,output)
    2222  {
    2323    using namespace std;
     
    4747        lstat(fullpath.c_str(),&nodestat);   // C api from sys/stat.h
    4848        if (S_ISDIR(nodestat.st_mode))       // C api from sys/stat.h
    49           daughters_.push_back(new Directory(fullpath));
     49          daughters_.push_back(new Directory(fullpath, output_name_+"_"));
    5050        else
    51           daughters_.push_back(new File(fullpath));
     51          daughters_.push_back(new File(fullpath,output_name_+"_"));
    5252      }
    5353  }
     
    7373  void Directory::print(const std::string& path) const
    7474  {
    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");
     75    std::string output(path + output_name_ + ".html");
    7976    std::ofstream os(output.c_str());
    8077    print_header(os);
     
    9188    os.close();
    9289
     90    // Peter, use STL algo.
    9391    for (NodeConstIter_ i=daughters_.begin();i!=daughters_.end();i++)
    94       (*i)->print(path+name()+"/");
     92      (*i)->print(path);
    9593  }
    96 
    97   void Directory::print_link(std::ostream& os) const
    98   {
    99     os << "<a href=\"" << name() << "/index.html\">" << name() << "</a>";
    100   }
    101 
    10294
    10395  void Directory::purge(void) {
  • trunk/lib/Directory.h

    r23 r29  
    3030    /// traversed.
    3131    ///
    32     Directory(const std::string& path);
     32    Directory(const std::string& path, const std::string& output="");
    3333
    3434    ///
     
    4040
    4141    void print(const std::string&) const;
    42 
    43     void print_link(std::ostream&) const;
    4442
    4543    void purge(void);
  • trunk/lib/File.cc

    r23 r29  
    9090  void File::print(const std::string& path) const
    9191  {
    92     std::string output(path + name() + ".html");
     92    std::string output(path + output_name_ + ".html");
    9393    std::ofstream os(output.c_str());
    9494    print_header(os);
     
    101101  }
    102102
    103   void File::print_link(std::ostream& os) const
    104   {
    105     os << "<a href=\"" << name() << ".html\">" << name() << "</a>";
    106   }
    107 
    108103}} // end of namespace svnstat and namespace theplu
  • trunk/lib/File.h

    r23 r29  
    1717    /// @brief Default Constructor
    1818    ///
    19     inline File(const std::string& path) : Node(path), binary_(false) {}
     19    File(const std::string& path, const std::string& output="")
     20      : Node(path,output), binary_(false) {}
    2021
    2122    ///
     
    3031    ///
    3132    void print(const std::string& path) const;
    32 
    33     ///
    34     ///
    35     ///
    36     void print_link(std::ostream&) const;
    3733
    3834  private:
  • trunk/lib/Node.cc

    r23 r29  
    1111namespace theplu{
    1212namespace svnstat{
     13
     14  Node::Node(const std::string& path, const std::string& output)
     15    : path_(path)
     16  {
     17    output_name_ = output + name();
     18  }
     19
    1320
    1421  std::string Node::name(void) const
  • trunk/lib/Node.h

    r23 r29  
    66#include "Stats.h"
    77
     8#include <ostream>
    89#include <string>
    910
     
    2021    /// @brief Constructor
    2122    ///
    22     inline Node(const std::string& path) : path_(path) {}
     23    Node(const std::string& path, const std::string& output="");
    2324
    2425    ///
     
    4041    /// Prints a html link.
    4142    ///
    42     virtual void print_link(std::ostream&) const=0;
    43 
     43    inline void print_link(std::ostream& os) const
     44    { os << "<a href=\"" << output_name_ << ".html\">" << name() << "</a>"; }
     45 
    4446    ///
    4547    ///
    4648    ///
    47     // Peter to Jari, inlining virtual functions?
    4849    inline virtual void purge(void) { /* Nothing to be done */ };
    4950
     
    7475    void print_header(std::ostream&) const;
    7576
     77    std::string output_name_; //without suffix
    7678    std::string path_;
    7779    Stats stats_;
     
    8284    ///
    8385    Node(const Node&);
     86
    8487  };
    8588
Note: See TracChangeset for help on using the changeset viewer.