From d377d47a6eef0e046a7a4e231c5c25e9e8066411 Mon Sep 17 00:00:00 2001 From: Reinhard Prix Date: Sun, 14 Jan 2007 23:04:27 +0000 Subject: [PATCH] make dir_hier_move and dir_hier_path output a help-string svn path=/trunk/boinc/; revision=11857 --- checkin_notes | 6 ++++++ tools/dir_hier_move.C | 14 ++++++++++++-- tools/dir_hier_path.C | 14 +++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/checkin_notes b/checkin_notes index 95ff5fce36..6c0afd8667 100755 --- a/checkin_notes +++ b/checkin_notes @@ -533,5 +533,11 @@ Rom 13 Jan 2007 Reinhard 14 Jan 2007 - install validate_util.h for external building of validators + - make dir_hier_move and dir_hier_path output help/usage strings + sched/ Makefile.am + + tools/ + dir_hier_move.C + dir_hier_path.C \ No newline at end of file diff --git a/tools/dir_hier_move.C b/tools/dir_hier_move.C index 5789cfe774..ec908f8c3d 100644 --- a/tools/dir_hier_move.C +++ b/tools/dir_hier_move.C @@ -32,6 +32,10 @@ #include "util.h" #include "sched_util.h" +const char *usage = +"\nUsage: dir_hier_move \n" +"Moves files from (flat) into (hierarchical) with the given \n\n"; + int main(int argc, char** argv) { char* src_dir, *dst_dir; int fanout=0; @@ -39,11 +43,17 @@ int main(int argc, char** argv) { char dst_path[256], src_path[256]; int retval; - if (argc != 4) exit(1); + if ( (argc == 1) || !strcmp(argv[1], "-h") || !strcmp(argv[1],"--help") || (argc != 4) ) { + printf (usage); + exit(1); + } src_dir = argv[1]; dst_dir = argv[2]; fanout = atoi(argv[3]); - if (!fanout) exit(1); + if (!fanout) { + printf ( usage ); + exit(1); + } DirScanner scanner(src_dir); while (scanner.scan(filename)) { diff --git a/tools/dir_hier_path.C b/tools/dir_hier_path.C index c56737f16e..1a96d90724 100644 --- a/tools/dir_hier_path.C +++ b/tools/dir_hier_path.C @@ -30,11 +30,23 @@ #include "sched_config.h" #include "sched_util.h" -int main(int /*argc*/, char** argv) { + +const char *usage = +"\nUsage: dir_hier_path \n" +" Run this in a project's root directory.\n" +" Prints the absolute path of the file in the download hierarchy,\n" +" and creates the directory if needed.\n\n"; + +int main(int argc, char** argv) { SCHED_CONFIG config; char path[256]; int retval; + if ( (argc == 1) || !strcmp(argv[1], "-h") || !strcmp(argv[1],"--help") || (argc != 2) ) { + printf (usage); + exit(1); + } + retval = config.parse_file("."); if (retval) { fprintf(stderr, "Can't find config.xml; run this in project root dir\n");