From 98f15d74197eab4d570578e9ce794d674c01165c Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 18 Aug 2014 11:34:44 +0200 Subject: [PATCH] Implement fileExists() using access() instead of open/close --- src/utilities.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/utilities.cpp b/src/utilities.cpp index 66e2f1d..54ecf0e 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -89,12 +89,7 @@ string parentDir(string const& dir) { } bool fileExists(const string &file) { - fstream fin; - fin.open(file.c_str() ,ios::in); - bool exists = fin.is_open(); - fin.close(); - - return exists; + return access(file.c_str(), F_OK) == 0; } bool rmtree(string path) {