diff options
author | MÃ¥rten Kongstad <marten.kongstad@volvocars.com> | 2020-06-11 15:06:51 +0200 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2020-07-20 13:55:41 +0000 |
commit | 3abb504a0812bb77a5e88b78a54fca828a47c94f (patch) | |
tree | 51486f6d5c55d0cdcc057e31b6a819bec206d9d2 /cmds/idmap2/libidmap2/FileUtils.cpp | |
parent | dc91aaab2d3e8f162fead05d2ee56d6553db57cd (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
Diffstat (limited to 'cmds/idmap2/libidmap2/FileUtils.cpp')
-rw-r--r-- | cmds/idmap2/libidmap2/FileUtils.cpp | 60 |
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 |