Changeset 49


Ignore:
Timestamp:
Jan 14, 2006, 1:53:56 AM (16 years ago)
Author:
Jari Häkkinen
Message:

bin directory compiles but svnstat not finished.

Location:
trunk/bin
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Makefile.am

    r37 r49  
    55bin_PROGRAMS = svnstat
    66
    7 svnstat_SOURCES = svnstat.cc Parameter.cc
     7svnstat_SOURCES = Parameter.cc rmdirhier.cc svnstat.cc
    88
    9 EXTRA_DIST = Parameter.h
     9LDADD = @top_srcdir@/lib/libsvnstat.a
     10
     11INCLUDES = -I@top_srcdir@/lib
     12
     13clean-local:
     14  rm -rf svnstat_output *~
  • trunk/bin/Parameter.cc

    r39 r49  
    44
    55#include <iostream>
     6#include <stdexcept>
    67#include <string>
    78
     
    1011
    1112  Parameter::Parameter(const int argc,const char *argv[])
    12     : force_(false), outdir_("svnstat"), root_("."), verbose_(false)
     13    : force_(false), root_("."), targetdir_("svnstat_output"), verbose_(false)
    1314  {
    1415 
     
    1819      if (myargv=="-d" || myargv=="--directory"){
    1920        if (++i<argc){
    20           outdir_= std::string(argv[i]);
     21          targetdir_= std::string(argv[i]);
    2122          ok=true;
    2223        }
     
    4243        ok = true;
    4344      }
    44       if (!ok){
    45         std::cerr << "svnstat: invalid option: " << myargv << "\n"
    46                   << "Type 'svnstat --help' for usage." << std::endl;
    47         exit(-1);
    48       }
     45
     46      if (!ok)
     47        throw std::runtime_error("svnstat: invalid option: " + myargv +
     48                                 "\nType 'svnstat --help' for usage.");
    4949    }
    5050
     
    7171              << "\n"
    7272              << "Valid options:\n"
    73               << "  -d [--dir] arg : output directory [svnstat]\n"
    74               << "  -f [--force]   : overwrite existing files\n"
     73              << "  -d [--dir] arg : output target directory [svnstat_output]\n"
     74              << "  -f [--force]   : remove target directory/file if it exists\n"
     75              << "                   [no force]\n"
    7576              << "  -h [--help]    : display this help and exit\n"
    7677              << "  -v [--verbose] : explain what is being done\n"
  • trunk/bin/Parameter.h

    r37 r49  
    1414    Parameter(const int argc,const char *argv[]);
    1515    inline bool force(void) const { return force_; }
    16     inline const std::string& outdir(void) const { return outdir_; }
    1716    inline const std::string& root(void) const { return root_; }
     17    inline const std::string& targetdir(void) const { return targetdir_; }
    1818    inline bool verbose(void) const { return verbose_; }
    1919
     
    2424
    2525    bool force_;
    26     std::string outdir_;
    2726    std::string root_;
     27    std::string targetdir_;
    2828    bool verbose_;
    29    
     29
    3030  };
    3131
  • trunk/bin/svnstat.cc

    r40 r49  
    22
    33#include "Parameter.h"
     4#include "Directory.h"
     5
     6#include <stdexcept>
     7#include <string>
     8#include <sys/stat.h>
     9#include <unistd.h>
     10
     11#include <iostream>
     12
     13using namespace std;
     14
     15///
     16/// Create directory \a dir. The call can fail in many ways, cf. 'man
     17/// mkdir'. If the \a dir exists, setting \a force to true will
     18/// trigger a recursive removal of the target \a dir.
     19///
     20int createdir(const string& dir, bool force=false);
     21
    422
    523int main(const int argc,const char* argv[])
     
    826  Parameter option(argc,argv);
    927
     28  if (createdir(option.targetdir(),option.force()))
     29    throw runtime_error("Failed to create target directory '" +
     30                        option.targetdir());
     31
     32  /*
     33  Directory tree(option.root());
     34  tree.purge();
     35  tree.parse();
     36
     37  Stats::gnuplot_pipe_.command("cd 'svnstat_output'");
     38  chdir("svnstat_output");
     39  system("ln -fns testrepo.html index.html");
     40  tree.print("./");
     41  */
     42
    1043  exit(0);        // normal exit
    1144}
     45
     46
     47int createdir(const string& dir, bool force)
     48{
     49  struct stat buf;
     50  if (force && !stat(dir.c_str(),&buf)) {
     51    std::cerr << "Remove item '" << dir << "'."
     52              << std::endl;
     53    std::cerr << unlink(dir.c_str()) << std::endl;
     54  }
     55
     56  return mkdir(dir.c_str(),0777);
     57}
Note: See TracChangeset for help on using the changeset viewer.