summaryrefslogtreecommitdiff
path: root/cmds/idmap2/libidmap2/FileUtils.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-12-14 20:42:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-12-14 20:42:03 +0000
commit314863c132479b108f0ce61a5a753123cd3a15ca (patch)
tree8c2c62e7f5964b3ed503f1f2c753d0850ac70dec /cmds/idmap2/libidmap2/FileUtils.cpp
parent2991744d472491889d9ba465c8f96c1022af5df0 (diff)
parenta45506e6f6619f59ce1ae94b20ad377b86966be0 (diff)
Merge changes from topic "inc-hard-am"
* changes: Revert^2 "Cache resolved theme values" Set resource id correctly when resolve fails Revert^2 "libandroidfw hardening for IncFs" idmap2: remove call to obsolete 'idmap2 verify' from valgrind.sh idmap2: remove the 'scan' command
Diffstat (limited to 'cmds/idmap2/libidmap2/FileUtils.cpp')
-rw-r--r--cmds/idmap2/libidmap2/FileUtils.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/cmds/idmap2/libidmap2/FileUtils.cpp b/cmds/idmap2/libidmap2/FileUtils.cpp
index 3e8e32989a09..3af1f70ebe39 100644
--- a/cmds/idmap2/libidmap2/FileUtils.cpp
+++ b/cmds/idmap2/libidmap2/FileUtils.cpp
@@ -16,19 +16,7 @@
#include "idmap2/FileUtils.h"
-#include <dirent.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <cerrno>
-#include <climits>
-#include <cstdlib>
-#include <cstring>
-#include <fstream>
-#include <memory>
#include <string>
-#include <utility>
-#include <vector>
#include "android-base/file.h"
#include "android-base/macros.h"
@@ -37,54 +25,6 @@
namespace android::idmap2::utils {
-std::unique_ptr<std::vector<std::string>> FindFiles(const std::string& root, bool recurse,
- const FindFilesPredicate& predicate) {
- DIR* dir = opendir(root.c_str());
- if (dir == nullptr) {
- return nullptr;
- }
- std::unique_ptr<std::vector<std::string>> vector(new std::vector<std::string>());
- struct dirent* dirent;
- while ((dirent = readdir(dir)) != nullptr) {
- const std::string path = root + "/" + dirent->d_name;
- if (predicate(dirent->d_type, path)) {
- vector->push_back(path);
- }
- if (recurse && dirent->d_type == DT_DIR && strcmp(dirent->d_name, ".") != 0 &&
- strcmp(dirent->d_name, "..") != 0) {
- auto sub_vector = FindFiles(path, recurse, predicate);
- if (!sub_vector) {
- closedir(dir);
- return nullptr;
- }
- vector->insert(vector->end(), sub_vector->begin(), sub_vector->end());
- }
- }
- closedir(dir);
-
- return vector;
-}
-
-std::unique_ptr<std::string> ReadFile(const std::string& path) {
- std::unique_ptr<std::string> str(new std::string());
- std::ifstream fin(path);
- str->append({std::istreambuf_iterator<char>(fin), std::istreambuf_iterator<char>()});
- fin.close();
- return str;
-}
-
-std::unique_ptr<std::string> ReadFile(int fd) {
- static constexpr const size_t kBufSize = 1024;
-
- std::unique_ptr<std::string> str(new std::string());
- char buf[kBufSize];
- ssize_t r;
- while ((r = read(fd, buf, sizeof(buf))) > 0) {
- str->append(buf, r);
- }
- return r == 0 ? std::move(str) : nullptr;
-}
-
#ifdef __ANDROID__
bool UidHasWriteAccessToPath(uid_t uid, const std::string& path) {
// resolve symlinks and relative paths; the directories must exist