Changeset 100 for trunk


Ignore:
Timestamp:
Jun 19, 2006, 11:53:16 AM (15 years ago)
Author:
Peter Johansson
Message:

closes #9 and move create function from svnstat.cc to lib/utility and also move rmdirhier to lib

Location:
trunk
Files:
11 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/bin/Makefile.am

    r96 r100  
    2424bin_PROGRAMS = svnstat
    2525
    26 svnstat_SOURCES = Parameter.cc rmdirhier.cc svnstat.cc
     26svnstat_SOURCES = Parameter.cc svnstat.cc
    2727
    28 noinst_HEADERS = Parameter.h rmdirhier.h
     28noinst_HEADERS = Parameter.h
    2929
    3030LDADD = @top_srcdir@/lib/libsvnstat.a -L$(APR_PATH)/lib -L$(SVN_PATH)/lib \
  • trunk/bin/svnstat.cc

    r92 r100  
    2929#include "rmdirhier.h"
    3030#include "SVN.h"
     31#include "utility.h"
    3132
    3233#include <iostream>
     
    3738
    3839using namespace std;
    39 
    40 ///
    41 /// Create directory \a dir. The call can fail in many ways, cf. 'man
    42 /// mkdir'. If the \a dir exists, setting \a force to true will
    43 /// trigger a recursive removal of the target \a dir.
    44 ///
    45 int createdir(const string& dir, bool force=false);
    46 
    4740
    4841int main(const int argc,const char* argv[])
     
    7568  }
    7669
    77   Directory tree(option.root(),"svnstat_");
     70  Directory tree(option.root(),"");
    7871  tree.parse(option.verbose());
    7972
     
    8679    std::cerr << "svnstat: " << x.what() << std::endl;
    8780  }
    88   string htmltopnode=tree.output_name()+".html";
    89   symlink(htmltopnode.c_str(),"index.html");
     81  //string htmltopnode=tree.output_name()+"/index.html";
     82  //symlink(htmltopnode.c_str(),"index.html");
    9083
    9184  exit(0);        // normal exit
     
    9386
    9487
    95 int createdir(const string& dir, bool force)
    96 {
    97   struct stat buf;
    98   if (force && !stat(dir.c_str(),&buf))
    99     theplu::svnstat::rmdirhier(dir);
    100 
    101   return mkdir(dir.c_str(),0777);
    102 }
  • trunk/lib/Directory.cc

    r91 r100  
    2626#include "Node.h"
    2727#include "SVN.h"
     28#include "utility.h"
    2829
    2930#include <algorithm>
     
    6869          lstat(fullpath.c_str(),&nodestat);   // C api from sys/stat.h
    6970          if (S_ISDIR(nodestat.st_mode))       // C api from sys/stat.h
    70             daughters_.push_back(new Directory(fullpath, output_name()+"_"));
     71            daughters_.push_back(new Directory(fullpath, output_name()+"/"));
    7172          else
    72             daughters_.push_back(new File(fullpath,output_name()+"_"));
     73            daughters_.push_back(new File(fullpath,output_name()+"/"));
    7374          break;
    7475        case SVN::unresolved:
     
    8687  }
    8788
     89  std::string Directory::html_link(void) const
     90  {
     91    return "<a href=\"" + name() + "/index.html\">" + name() + "</a>";
     92  }
    8893
    8994  const Stats& Directory::parse(const bool verbose)
     
    100105  void Directory::print(const bool verbose) const
    101106  {
    102     std::string output(output_name() + ".html");
     107    createdir(output_name());
     108    std::string output(output_name() + "/index.html");
    103109    if (verbose)
    104110      std::cout << "Printing output for " << path_ << std::endl;
    105111    std::ofstream os(output.c_str());
    106112    print_header(os);
    107     os << "<p align=center>\n<img src='" << stats_.plot(output_name()+".png")
     113    os << "<p align=center>\n<img src='"
     114       << file_name(stats_.plot(output_name()+"/index.png"))
    108115       << "' alt='[plot]' border=0><br>\n";
    109116    os << "<table>\n";
  • trunk/lib/Directory.h

    r91 r100  
    5959    ~Directory(void);
    6060
     61    ///
     62    /// @return A properly formatted html link to this directory.
     63    ///
     64    std::string html_link(void) const;
     65   
    6166    const Stats& parse(const bool verbose=false);
    6267
  • trunk/lib/File.cc

    r84 r100  
    3636namespace svnstat{
    3737
     38  std::string File::html_link(void) const
     39  {
     40    return "<a href=\"" + name() + ".html\">" + name() + "</a>";
     41  }
     42
     43
    3844  const Stats& File::parse(const bool verbose)
    3945  {
     
    5864    std::ofstream os(output.c_str());
    5965    print_header(os);
    60     os << "<p align=center>\n<img src='" << stats_.plot(output_name()+".png")
     66    os << "<p align=center>\n<img src='"
     67       << file_name(stats_.plot(output_name_+".png"))
    6168       << "' alt='[plot]' border=0>\n</p>";
    6269    print_footer(os);
  • trunk/lib/File.h

    r84 r100  
    4141      : Node(path,output), binary_(false), ignore_(false) {}
    4242
     43    ///
     44    /// @return A properly formatted html link to this node.
     45    ///
     46    std::string html_link(void) const;
     47
    4348    ///
    4449    /// Parsing out information from svn repository
  • trunk/lib/Makefile.am

    r96 r100  
    2626
    2727noinst_HEADERS = CommitStat.h Directory.h File.h Gnuplot.h GnuplotFE.h  \
    28   Node.h Stats.h SVN.h utility.h
     28  Node.h rmdirhier.h Stats.h SVN.h utility.h
    2929
    3030libsvnstat_a_SOURCES = CommitStat.cc Directory.cc File.cc Gnuplot.cc  \
    31   GnuplotFE.cc Node.cc Stats.cc SVN.cc utility.cc
     31  GnuplotFE.cc Node.cc rmdirhier.cc Stats.cc SVN.cc utility.cc
    3232
    3333INCLUDES = -I$(SVN_PATH)/include/subversion-1 -I$(APR_PATH)/include/apr-0
  • trunk/lib/Node.cc

    r91 r100  
    2424#include "Node.h"
    2525#include "utility.h"
     26#include <config.h> // this header file is created by configure
    2627
    2728#include <ctime>
     
    3334namespace svnstat{
    3435
    35 
    36   std::string Node::name(void) const
    37   {
    38     std::stringstream ss(path_);
    39     std::string name;
    40     while (getline(ss,name,'/')) {}
    41     return name;
     36  Node::Node(const std::string& path, const std::string& output="")
     37      : path_(path), stats_(path)
     38  {
     39    output_name_ = output+file_name(path_);
    4240  }
    43 
    4441
    4542  void Node::print_footer(std::ostream& os) const
     
    5148    os << "<p align=center><font size=-2>Generated on "
    5249       << asctime (timeinfo)
    53        << "by <a href=http://lev.thep.lu.se/trac/svnstat/>svnstat</a>"
     50       << "by <a href=http://lev.thep.lu.se/trac/svnstat/>"
     51       << PACKAGE_STRING << "</a>"
    5452       << "</font></p></body>\n</html>\n";
    5553  }
  • trunk/lib/Node.h

    r91 r100  
    2626
    2727#include "Stats.h"
     28#include "utility.h"
    2829
    2930#include <ostream>
     
    5758    /// @brief Constructor
    5859    ///
    59     Node(const std::string& path, const std::string& output="")
    60       : path_(path), stats_(path)
    61       { output_name_ = output + name(); }
     60    Node(const std::string&, const std::string&);
    6261
    6362    ///
     
    6968    /// @return A properly formatted html link to this node.
    7069    ///
    71     inline std::string html_link(void) const
    72     { return "<a href=\"" + output_name() + ".html\">" + name() + "</a>"; }
     70    virtual std::string html_link(void) const=0;
    7371
    7472    inline std::string html_tablerow(void) const
     
    8078    }
    8179
     80    ///
     81    /// @return
     82    ///
    8283    inline const std::string& output_name(void) const { return output_name_; }
    8384
     
    100101    /// @return name of node (not full path)
    101102    ///
    102     std::string name(void) const;
     103    inline std::string name(void) const { return file_name(path_); }
    103104
    104105    ///
  • trunk/lib/utility.cc

    r84 r100  
    2323
    2424#include "utility.h"
     25#include "rmdirhier.h"
    2526
    2627#include <fstream>
     
    2930#include <sstream>
    3031#include <string>
     32#include <sys/stat.h>
    3133
    3234namespace theplu{
     
    4042      std::cerr << "Error: svn blame " << path << std::endl;     
    4143    return system_return;
     44  }
     45
     46  int createdir(const std::string& dir, bool force)
     47  {
     48    struct stat buf;
     49    if (force && !stat(dir.c_str(),&buf))
     50      rmdirhier(dir);
     51
     52    return mkdir(dir.c_str(),0777);
     53  }
     54
     55  std::string file_name(const std::string& full_path)
     56  {
     57    std::stringstream ss(full_path);
     58    std::string name;
     59    while (getline(ss,name,'/')) {}
     60    return name;
    4261  }
    4362
     
    6180  }
    6281
     82
     83
     84
    6385}} // end of namespace svnstat and namespace theplu
  • trunk/lib/utility.h

    r84 r100  
    3939  ///
    4040  int blame(const std::string&);
     41 
     42  ///
     43  /// Create directory \a dir. The call can fail in many ways, cf. 'man
     44  /// mkdir'. If the \a dir exists, setting \a force to true will
     45  /// trigger a recursive removal of the target \a dir.
     46  ///
     47  int createdir(const std::string& dir, bool force=false);
     48
     49  ///
     50  /// @return everything after last '/'
     51  ///
     52  std::string file_name(const std::string&);
    4153
    4254  ///
Note: See TracChangeset for help on using the changeset viewer.