Use IO delegates to create path in compile_aidl_to_java

Change-Id: I654e97d4149b0eb247fb683f9fefc2a7121f3507
Test: Unit tests pass
Signed-off-by: Casey Dahlin <sadmac@google.com>
diff --git a/io_delegate.cpp b/io_delegate.cpp
index ecaaae4..6e5130a 100644
--- a/io_delegate.cpp
+++ b/io_delegate.cpp
@@ -26,6 +26,8 @@
 #include <sys/stat.h>
 #endif
 
+#include <base/strings.h>
+
 #include "logging.h"
 #include "os.h"
 
@@ -33,6 +35,8 @@
 using std::unique_ptr;
 using std::vector;
 
+using android::base::Split;
+
 namespace android {
 namespace aidl {
 
@@ -95,6 +99,22 @@
   return true;
 }
 
+bool IoDelegate::CreatePathForFile(const string& path) const {
+  if (path.empty()) {
+    return true;
+  }
+
+  string base = ".";
+  if (path[0] == OS_PATH_SEPARATOR) {
+    base = "/";
+  }
+
+  auto split = Split(path, string{1u, OS_PATH_SEPARATOR});
+  split.pop_back();
+
+  return CreatedNestedDirs(base, split);
+}
+
 unique_ptr<CodeWriter> IoDelegate::GetCodeWriter(
     const string& file_path) const {
   return GetFileWriter(file_path);