diff options
author | Adam Lesinski <adamlesinski@google.com> | 2014-01-23 18:17:42 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2014-01-27 10:31:04 -0800 |
commit | 282e181b58cf72b6ca770dc7ca5f91f135444502 (patch) | |
tree | e313e7ab30ff4679562efa37bde29cfcb9e375d3 /tools/aapt/FileFinder.h | |
parent | 7023df08f14ec5dee76ac54c03e870f84e297636 (diff) | |
download | frameworks_base-282e181b58cf72b6ca770dc7ca5f91f135444502.zip frameworks_base-282e181b58cf72b6ca770dc7ca5f91f135444502.tar.gz frameworks_base-282e181b58cf72b6ca770dc7ca5f91f135444502.tar.bz2 |
Revert "Move frameworks/base/tools/ to frameworks/tools/"
This reverts commit 9f6a119c8aa276432ece4fe2118bd8a3c9b1067e.
Diffstat (limited to 'tools/aapt/FileFinder.h')
-rw-r--r-- | tools/aapt/FileFinder.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/aapt/FileFinder.h b/tools/aapt/FileFinder.h new file mode 100644 index 0000000..6974aee --- /dev/null +++ b/tools/aapt/FileFinder.h @@ -0,0 +1,80 @@ +// +// Copyright 2011 The Android Open Source Project +// + +// File Finder. +// This is a collection of useful functions for finding paths and modification +// times of files that match an extension pattern in a directory tree. +// and finding files in it. + +#ifndef FILEFINDER_H +#define FILEFINDER_H + +#include <utils/Vector.h> +#include <utils/KeyedVector.h> +#include <utils/String8.h> + +#include "DirectoryWalker.h" + +using namespace android; + +// Abstraction to allow for dependency injection. See MockFileFinder.h +// for the testing implementation. +class FileFinder { +public: + virtual bool findFiles(String8 basePath, Vector<String8>& extensions, + KeyedVector<String8,time_t>& fileStore, + DirectoryWalker* dw) = 0; + + virtual ~FileFinder() {}; +}; + +class SystemFileFinder : public FileFinder { +public: + + /* findFiles takes a path, a Vector of extensions, and a destination KeyedVector + * and places path/modification date key/values pointing to + * all files with matching extensions found into the KeyedVector + * PRECONDITIONS + * path is a valid system path + * extensions should include leading "." + * This is not necessary, but the comparison directly + * compares the end of the path string so if the "." + * is excluded there is a small chance you could have + * a false positive match. (For example: extension "png" + * would match a file called "blahblahpng") + * + * POSTCONDITIONS + * fileStore contains (in no guaranteed order) paths to all + * matching files encountered in subdirectories of path + * as keys in the KeyedVector. Each key has the modification time + * of the file as its value. + * + * Calls checkAndAddFile on each file encountered in the directory tree + * Recursively descends into subdirectories. + */ + virtual bool findFiles(String8 basePath, Vector<String8>& extensions, + KeyedVector<String8,time_t>& fileStore, + DirectoryWalker* dw); + +private: + /** + * checkAndAddFile looks at a single file path and stat combo + * to determine whether it is a matching file (by looking at + * the extension) + * + * PRECONDITIONS + * no setup is needed + * + * POSTCONDITIONS + * If the given file has a matching extension then a new entry + * is added to the KeyedVector with the path as the key and the modification + * time as the value. + * + */ + static void checkAndAddFile(String8 path, const struct stat* stats, + Vector<String8>& extensions, + KeyedVector<String8,time_t>& fileStore); + +}; +#endif // FILEFINDER_H |