Remove almost unused code from filesystem.cpp/.h 81/236581/3
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 18 Jun 2020 07:52:36 +0000 (09:52 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 18 Jun 2020 12:15:38 +0000 (14:15 +0200)
fileSize was used only in one place, in tests

Change-Id: Ib2580f488c65d379059cf977f9533e27e93bdd47

src/common/filesystem.cpp
src/common/include/filesystem.h
test/test_privilege_db_migration.cpp

index 371cd1f54e0d7a6771f5c4a16c8509f3df3e6895..31e21b8e9a68c0554eeb83711971aa4a90f302cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2016 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2016 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Contact: Rafal Krypa <r.krypa@samsung.com>
  *
@@ -208,12 +208,5 @@ int overwriteFile(const std::string &srcPath, const std::string &dstPath) {
     return src && dst ? SECURITY_MANAGER_SUCCESS : SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED;
 }
 
-off_t fileSize(const std::string &path) {
-    struct stat st;
-    static_assert(std::is_same<off_t, decltype(st.st_size)>::value);
-    static_assert(std::is_signed<off_t>::value);
-    return -1 == lstat(path.c_str(), &st) || !S_ISREG(st.st_mode) ? -1 : st.st_size;
-}
-
 } // namespace FS
 } // namespace SecurityManager
index 2eca8080245a89afc7f640aaae136389cecb3876..8c7d675ef896ac7f11dc553587505cd18788b68e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2016 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2016 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Contact: Rafal Krypa <r.krypa@samsung.com>
  *
@@ -47,7 +47,6 @@ bool fileExists(const std::string &path);
 int removeFile(const std::string &path);
 int symLink(const std::string &src, const std::string &dst);
 int overwriteFile(const std::string &src, const std::string &dst);
-off_t fileSize(const std::string &path); // < 0 on error
 
 } // namespace FS
 } // namespace SecurityManager
index 53935491161108ec14cdc6ae03bec1c0f1514543..060e7b4345b42cd49b69d8841b7a86e42f888221 100644 (file)
@@ -181,7 +181,7 @@ POSITIVE_TEST_CASE(T1570_fallback_canonicity) {
         if (empty)
             BOOST_REQUIRE(fileContentsSame(TEST_DB_PATH DB_JOURNAL_SUFFIX, PRIVILEGE_DB_TEMPLATE DB_JOURNAL_SUFFIX));
         else
-            BOOST_REQUIRE(!FS::fileSize(TEST_DB_PATH DB_JOURNAL_SUFFIX));
+            BOOST_REQUIRE(fileEmpty(TEST_DB_PATH DB_JOURNAL_SUFFIX));
     };
     go({},                        Marker::fallback, false);
     go({},                        Marker::fallback, true);