File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -203,3 +203,12 @@ bool create_directory(const std::string &path)
203
203
return mkdir (path.c_str (), 0777 ) == 0 ;
204
204
#endif
205
205
}
206
+
207
+ bool file_exists (const std::string &path)
208
+ {
209
+ #ifdef _WIN32
210
+ return _waccess (utf8_to_utf16_native_endian (path).c_str (), 0 ) == 0 ;
211
+ #else
212
+ return access (path.c_str (), F_OK) == 0 ;
213
+ #endif
214
+ }
Original file line number Diff line number Diff line change @@ -32,4 +32,9 @@ bool is_directory(const std::string &path);
32
32
// / \return true iff the directory was created
33
33
bool create_directory (const std::string &path);
34
34
35
+ // / Check whether file with given path exists.
36
+ // / C++17 will allow us to use std::filesystem::directory_entry(file).exists()
37
+ // / \return true iff the file exists
38
+ bool file_exists (const std::string &path);
39
+
35
40
#endif // CPROVER_UTIL_FILE_UTIL_H
You can’t perform that action at this time.
0 commit comments