- Timestamp:
- Jan 14, 2006, 1:53:56 AM (17 years ago)
- Location:
- trunk/bin
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/Makefile.am
r37 r49 5 5 bin_PROGRAMS = svnstat 6 6 7 svnstat_SOURCES = svnstat.cc Parameter.cc7 svnstat_SOURCES = Parameter.cc rmdirhier.cc svnstat.cc 8 8 9 EXTRA_DIST = Parameter.h 9 LDADD = @top_srcdir@/lib/libsvnstat.a 10 11 INCLUDES = -I@top_srcdir@/lib 12 13 clean-local: 14 rm -rf svnstat_output *~ -
trunk/bin/Parameter.cc
r39 r49 4 4 5 5 #include <iostream> 6 #include <stdexcept> 6 7 #include <string> 7 8 … … 10 11 11 12 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) 13 14 { 14 15 … … 18 19 if (myargv=="-d" || myargv=="--directory"){ 19 20 if (++i<argc){ 20 outdir_= std::string(argv[i]);21 targetdir_= std::string(argv[i]); 21 22 ok=true; 22 23 } … … 42 43 ok = true; 43 44 } 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."); 49 49 } 50 50 … … 71 71 << "\n" 72 72 << "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" 75 76 << " -h [--help] : display this help and exit\n" 76 77 << " -v [--verbose] : explain what is being done\n" -
trunk/bin/Parameter.h
r37 r49 14 14 Parameter(const int argc,const char *argv[]); 15 15 inline bool force(void) const { return force_; } 16 inline const std::string& outdir(void) const { return outdir_; }17 16 inline const std::string& root(void) const { return root_; } 17 inline const std::string& targetdir(void) const { return targetdir_; } 18 18 inline bool verbose(void) const { return verbose_; } 19 19 … … 24 24 25 25 bool force_; 26 std::string outdir_;27 26 std::string root_; 27 std::string targetdir_; 28 28 bool verbose_; 29 29 30 30 }; 31 31 -
trunk/bin/svnstat.cc
r40 r49 2 2 3 3 #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 13 using 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 /// 20 int createdir(const string& dir, bool force=false); 21 4 22 5 23 int main(const int argc,const char* argv[]) … … 8 26 Parameter option(argc,argv); 9 27 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 10 43 exit(0); // normal exit 11 44 } 45 46 47 int 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.