From 3a3f417181935b2233f3fc705d8abfafea7d1463 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 12 Jun 2017 20:42:05 +0200 Subject: [PATCH] better way to check file existence --- main.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/main.cc b/main.cc index 3c436a6..1a3bf39 100644 --- a/main.cc +++ b/main.cc @@ -65,18 +65,14 @@ static bool ob_check_ts( return false; } -static bool ob_check_file(string_range fname) { - return ostd::file_stream{fname, ostd::stream_mode::READ}.is_open(); -} - static bool ob_check_exec( string_range tname, std::vector const &deps ) { - if (!ob_check_file(tname)) { + if (!fs::exists(std::string{tname})) { return true; } for (auto &dep: deps) { - if (!ob_check_file(dep)) { + if (!fs::exists(dep)) { return true; } } @@ -315,7 +311,7 @@ struct ob_state: cs_state { exec_action(rlist[0].rule); return; } - if (rlist.empty() && !ob_check_file(target)) { + if (rlist.empty() && !fs::exists(std::string{target})) { if (from.empty()) { throw build_error{"no rule to run target '%s'", target}; } else {