summaryrefslogtreecommitdiff
path: root/cmds/idmap2/libidmap2/FileUtils.cpp
diff options
context:
space:
mode:
authorMÃ¥rten Kongstad <marten.kongstad@volvocars.com>2020-06-11 15:06:51 +0200
committerRyan Mitchell <rtmitchell@google.com>2020-12-08 16:54:51 +0000
commit6532483950eb0e75a5caf9645cae5ef4ac02fffc (patch)
treeba062214ae076009419ff0dc6f6cf23f4a12e40e /cmds/idmap2/libidmap2/FileUtils.cpp
parentf3e5403f7174ff36e3b75bb1a8307b573ad4dd54 (diff)
idmap2: remove the 'scan' command
The 'scan' command has been replaced by 'create-multiple'. Remove the unused code. Also remove unused functions and #includes from FileUtils, and the obsolete JNI plumbing. Test: atest idmap2_tests OverlayDeviceTests OverlayHostTests Change-Id: Iae073c13ce64b5db48f22f7e723bc8c0c5fcd2c9 Merged-In: Iae073c13ce64b5db48f22f7e723bc8c0c5fcd2c9
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