Change flie existentce checking method 24/324524/2 tizen_8.0
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 20 May 2025 05:35:41 +0000 (14:35 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 20 May 2025 05:38:35 +0000 (14:38 +0900)
std::filesystem::exists() can throw exception.
To prevent this, we change that method to access().

Change-Id: Iaa2b90adb2fc62cf95d82d342f1f772b17de1c8d
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/launchpad-process-pool/loader_context.cc
src/launchpad-process-pool/logger.cc
src/lib/launchpad-common/procfs.cc
src/lib/launchpad-glib/util.cc

index f9b25a5c65b2321a6be31813e63e8f3dc34adb70..dca2bfbcf9ad5ec4ce98a6063ad0b20f69b4ce4a 100644 (file)
@@ -697,7 +697,7 @@ void LoaderContext::CreateReadyFile() {
   std::string path = "/tmp/." + std::to_string(getuid()) + "-" +
       GetLoaderName() + ".ready";
   std::filesystem::path file_path(path);
-  if (std::filesystem::exists(file_path)) {
+  if (access(file_path.c_str(), F_OK) == 0) {
     ready_file_created_ = true;
     return;
   }
index 689068cc2a35d4bc3b6f1cbd4159fc64230d1693..6501a0dfc85f139cf337c3a3e8cde8e356ab1049 100644 (file)
@@ -50,7 +50,7 @@ int SetSmackLabel(const std::string &path, const std::string &label) {
 }
 
 int CreateDirectory(const std::string &path) {
-  if (std::filesystem::exists(path))
+  if (access(path.c_str(), F_OK) == 0)
     return 0;
 
   try {
index 461b9dbcbdcadab0506bf88a30bfb7495674553a..9074952d0f4057a41eaae3b3de3532bf6b6848e7 100644 (file)
@@ -78,7 +78,7 @@ void Procfs::GetPssMemory(pid_t pid, uint64_t* mem_pss) {
   }
 
   std::filesystem::path smaps_path = "/proc/" + std::to_string(pid) + "/smaps";
-  if (!std::filesystem::exists(smaps_path)) {
+  if (access(smaps_path.c_str(), F_OK) != 0) {
     _E("%s does not exist", smaps_path.c_str());
     return;
   }
index 381ca37b72b5c664b9fbb67980442f1f1e0f6238..1c0ba06f39d5ee2be3ca22df889c55e20a5a82ae 100644 (file)
@@ -529,7 +529,7 @@ int Util::WaitTepMount(const AppInfo* app_info) {
 std::string Util::GetLibDirectory(const std::string& app_path) {
   std::filesystem::path path(app_path);
   auto lib_dir = path.parent_path().string() + "/../lib/";
-  if (std::filesystem::exists(lib_dir))
+  if (access(lib_dir.c_str(), F_OK) == 0)
     return lib_dir;
 
   return "";