Bazel client: implement directory tree walking

This change:

- merges the //src/{main,test}/cpp:file and
//src/{main,test}/cpp:file_platform libraries
because "file" and "file_platform" need each other
and this makes logical sense anyway

- implements a function in file_<platform> to run
a custom function on every child of a directory

- implements a function in file.cc to recursively
traverse a directory tree, based on the previosly
mentioned function

- removes the corresponding logic from the Bazel
client to make it more portable

--
MOS_MIGRATED_REVID=139309562
diff --git a/src/main/cpp/util/file_platform.h b/src/main/cpp/util/file_platform.h
index b0df5ea..c43be79 100644
--- a/src/main/cpp/util/file_platform.h
+++ b/src/main/cpp/util/file_platform.h
@@ -40,6 +40,27 @@
 // Changes the current working directory to `path`, returns true upon success.
 bool ChangeDirectory(const std::string& path);
 
+// Interface to be implemented by ForEachDirectoryEntry clients.
+class DirectoryEntryConsumer {
+ public:
+  virtual ~DirectoryEntryConsumer() {}
+
+  // This method is called for each entry in a directory.
+  // `name` is the full path of the entry.
+  // `is_directory` is true if this entry is a directory (but false if this is a
+  // symlink pointing to a directory).
+  virtual void Consume(const std::string &name, bool is_directory) = 0;
+};
+
+// Executes a function for each entry in a directory (except "." and "..").
+//
+// Returns true if the `path` referred to a directory or directory symlink,
+// false otherwise.
+//
+// See DirectoryEntryConsumer for more details.
+void ForEachDirectoryEntry(const std::string &path,
+                           DirectoryEntryConsumer *consume);
+
 }  // namespace blaze_util
 
 #endif  // BAZEL_SRC_MAIN_CPP_UTIL_FILE_PLATFORM_H_