Changeset 23 for trunk/lib/File.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/File.cc

    r16 r23  
    2222  }
    2323
     24  void File::info(void)
     25  {
     26    std::string system_call = "svn info " + path_ + " > svnstat.tmp";
     27    int system_return = system(system_call.c_str());
     28    if (system_return){
     29      // Jari, throw exception.
     30      std::cerr << "svnstat: svn info " << path_ << std::endl;     
     31      exit(-1);
     32    }
     33    std::ifstream is("svnstat.tmp");
     34    std::string line;
     35    while (getline(is,line)){
     36      std::stringstream ss(line);
     37      std::string tag;
     38      getline(ss,tag,':');
     39      if (tag == std::string("Last Changed Author"))
     40        ss >> author_;
     41      else if (tag == std::string("Last Changed Rev"))
     42        ss >> revision_;
     43    }
     44  }
     45
     46
    2447  const Stats& File::parse(void)
    2548  {
    2649    stats_.reset();
     50    info();
     51
    2752    if (binary_){
    2853      stats_.add(author_,revision_);
     
    4166      getline(is,line,' ');
    4267      if (line==std::string("binary")){
    43   is.close();
    44   binary_ = true;
    45   return parse();
     68        is.close();
     69        binary_ = true;
     70        return parse();
    4671      }
    4772    }
     
    5176    while (getline(is,line, '\n')){
    5277      if (!line.size()) // skip empty line
    53   continue;
     78        continue;
    5479      std::stringstream ss(line);
    5580      u_int revision;
     
    6388  }
    6489
    65   void File::print(void) {
    66     // Jari, temporary using this to print directory tree
    67     std::cout << "File '" << path_ << "'" << std::endl;
     90  void File::print(const std::string& path) const
     91  {
     92    std::string output(path + name() + ".html");
     93    std::ofstream os(output.c_str());
     94    print_header(os);
     95    os << std::endl;
     96    stats_.print(os);
     97    os << std::endl;
     98    print_footer(os);
     99    os.close();
     100
     101  }
     102
     103  void File::print_link(std::ostream& os) const
     104  {
     105    os << "<a href=\"" << name() << ".html\">" << name() << "</a>";
    68106  }
    69107
Note: See TracChangeset for help on using the changeset viewer.