From 80395ff9164a0d10d3d0a21db51030f653d0fa1a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 27 Dec 2015 01:28:16 +0300 Subject: utils: Boost.Filesystem for usage messages --- utils/CMakeLists.txt | 2 +- utils/block_cmd_parser.hpp | 5 +++-- utils/decrypt_block.cpp | 2 +- utils/decrypt_bmp.cpp | 2 +- utils/decrypt_file.cpp | 2 +- utils/encrypt_block.cpp | 2 +- utils/encrypt_bmp.cpp | 2 +- utils/encrypt_file.cpp | 2 +- utils/file_cmd_parser.hpp | 5 +++-- 9 files changed, 13 insertions(+), 11 deletions(-) (limited to 'utils') diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4643c5e..97ecfb6 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Boost REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS filesystem program_options system) add_executable(util_encrypt_block encrypt_block.cpp block_cmd_parser.hpp block_dumper.hpp data_parsers.hpp) target_include_directories(util_encrypt_block PRIVATE ${Boost_INCLUDE_DIRS}) diff --git a/utils/block_cmd_parser.hpp b/utils/block_cmd_parser.hpp index 708c241..3468d58 100644 --- a/utils/block_cmd_parser.hpp +++ b/utils/block_cmd_parser.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -42,8 +43,8 @@ namespace class CommandLineParser { public: - CommandLineParser(const char* prog_name) - : prog_name(prog_name) + CommandLineParser(const std::string& argv0) + : prog_name(boost::filesystem::path(argv0).filename().string()) , options("Options") { namespace po = boost::program_options; diff --git a/utils/decrypt_block.cpp b/utils/decrypt_block.cpp index b9f9d19..30409e0 100644 --- a/utils/decrypt_block.cpp +++ b/utils/decrypt_block.cpp @@ -185,7 +185,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("decrypt_block.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/decrypt_bmp.cpp b/utils/decrypt_bmp.cpp index 559b5d5..a326828 100644 --- a/utils/decrypt_bmp.cpp +++ b/utils/decrypt_bmp.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("decrypt_bmp.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/decrypt_file.cpp b/utils/decrypt_file.cpp index 092b249..96aec62 100644 --- a/utils/decrypt_file.cpp +++ b/utils/decrypt_file.cpp @@ -114,7 +114,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("decrypt_file.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp index 01ea745..022c237 100644 --- a/utils/encrypt_block.cpp +++ b/utils/encrypt_block.cpp @@ -185,7 +185,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("encrypt_block.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/encrypt_bmp.cpp b/utils/encrypt_bmp.cpp index 978b954..2f019d8 100644 --- a/utils/encrypt_bmp.cpp +++ b/utils/encrypt_bmp.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("encrypt_bmp.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/encrypt_file.cpp b/utils/encrypt_file.cpp index 9b5406c..d1dd5e8 100644 --- a/utils/encrypt_file.cpp +++ b/utils/encrypt_file.cpp @@ -114,7 +114,7 @@ int main(int argc, char** argv) { try { - CommandLineParser cmd_parser("encrypt_file.exe"); + CommandLineParser cmd_parser(argv[0]); try { cmd_parser.parse(argc, argv); diff --git a/utils/file_cmd_parser.hpp b/utils/file_cmd_parser.hpp index 15b6a45..cf5d188 100644 --- a/utils/file_cmd_parser.hpp +++ b/utils/file_cmd_parser.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -48,8 +49,8 @@ namespace class CommandLineParser { public: - CommandLineParser(const char* prog_name) - : prog_name(prog_name) + CommandLineParser(const std::string& argv0) + : prog_name(boost::filesystem::path(argv0).filename().string()) , options("Options") { namespace po = boost::program_options; -- cgit v1.2.3