From 893e9d89ddfc993d8c0f31c7d94a8824bb2f49c6 Mon Sep 17 00:00:00 2001 From: Valentin Laube Date: Mon, 24 Jul 2017 19:53:53 +0200 Subject: [PATCH 1/2] example for file_size usage --- path_demo.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/path_demo.cpp b/path_demo.cpp index 266c661..6d05e9e 100644 --- a/path_demo.cpp +++ b/path_demo.cpp @@ -25,10 +25,26 @@ int main(int argc, char **argv) { cout << "some/path.ext:operator==() (unequal) = " << (path("some/path.ext") == path("another/path.ext")) << endl; cout << "nonexistant:exists = " << path("nonexistant").exists() << endl; + try + { + cout << "nonexistant:file_size = " << path("nonexistant").file_size() << endl; + } + catch(std::runtime_error e) + { + cout << "" << endl; + } cout << "nonexistant:is_file = " << path("nonexistant").is_file() << endl; cout << "nonexistant:is_directory = " << path("nonexistant").is_directory() << endl; cout << "nonexistant:filename = " << path("nonexistant").filename() << endl; cout << "nonexistant:extension = " << path("nonexistant").extension() << endl; + try + { + cout << "filesystem/path.h:file_size = " << path("filesystem/path.h").file_size() << endl; + } + catch(std::runtime_error e) + { + cout << "" << endl; + } cout << "filesystem/path.h:exists = " << path("filesystem/path.h").exists() << endl; cout << "filesystem/path.h:is_file = " << path("filesystem/path.h").is_file() << endl; cout << "filesystem/path.h:is_directory = " << path("filesystem/path.h").is_directory() << endl; @@ -36,6 +52,14 @@ int main(int argc, char **argv) { cout << "filesystem/path.h:extension = " << path("filesystem/path.h").extension() << endl; cout << "filesystem/path.h:make_absolute = " << path("filesystem/path.h").make_absolute() << endl; cout << "../filesystem:exists = " << path("../filesystem").exists() << endl; + try + { + cout << "../filesystem:file_size = " << path("../filesystem").file_size() << endl; + } + catch(std::runtime_error e) + { + cout << "" << endl; + } cout << "../filesystem:is_file = " << path("../filesystem").is_file() << endl; cout << "../filesystem:is_directory = " << path("../filesystem").is_directory() << endl; cout << "../filesystem:extension = " << path("../filesystem").extension() << endl; From f0fce8e2b4eded43f56941bdfcf40ee17fa90662 Mon Sep 17 00:00:00 2001 From: Valentin Laube Date: Mon, 24 Jul 2017 21:49:45 +0200 Subject: [PATCH 2/2] use std::exception --- path_demo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/path_demo.cpp b/path_demo.cpp index 6d05e9e..eb62b21 100644 --- a/path_demo.cpp +++ b/path_demo.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) { { cout << "nonexistant:file_size = " << path("nonexistant").file_size() << endl; } - catch(std::runtime_error e) + catch(std::exception &e) { cout << "" << endl; } @@ -41,7 +41,7 @@ int main(int argc, char **argv) { { cout << "filesystem/path.h:file_size = " << path("filesystem/path.h").file_size() << endl; } - catch(std::runtime_error e) + catch(std::exception &e) { cout << "" << endl; } @@ -56,7 +56,7 @@ int main(int argc, char **argv) { { cout << "../filesystem:file_size = " << path("../filesystem").file_size() << endl; } - catch(std::runtime_error e) + catch(std::exception &e) { cout << "" << endl; }