Implement FileExists() in Utils

Add FileExists() method in Utils, which takes in a path name
and returns if the file exists.

Bug: 197736122
Test: manual
Signed-off-by: Robertas Norkus <robertasn@google.com>
Change-Id: Ibc03be602234bc5ebaecb1d2fa3932625001e8f5
diff --git a/include/ditto/utils.h b/include/ditto/utils.h
index 5cfb5b5..cd8d907 100644
--- a/include/ditto/utils.h
+++ b/include/ditto/utils.h
@@ -23,5 +23,6 @@
 
 int64_t GetFileSize(SyscallInterface& syscall, int fd);
 std::string GetFilePath(SyscallInterface& syscall, int fd);
+bool FileExists(SyscallInterface& syscall, const std::string& path_name);
 
 }  // namespace dittosuite
diff --git a/src/utils.cpp b/src/utils.cpp
index 4af8365..3874a31 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -31,4 +31,8 @@
   return std::string(file_path);
 }
 
+bool FileExists(SyscallInterface& syscall, const std::string& path_name) {
+  return syscall.Access(path_name, F_OK) != -1;
+}
+
 }  // namespace dittosuite