Change "-o" to create parent directories if it's needed.
Change-Id: I98de7f29d338c5849f5fcd7fb598c00150140d5a
diff --git a/slang.cpp b/slang.cpp
index 088f14f..886801a 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -153,9 +153,35 @@
return;
}
+static void _mkdir_given_a_file(const char *file) {
+ char tmp[256];
+ char *p = NULL;
+ size_t len;
+
+ if (strlen(file) > 255) {
+ printf("File name too long\n");
+ exit(1);
+ }
+ snprintf(tmp, sizeof(tmp), "%s", file);
+ len = strlen(tmp);
+
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
+
+ for (p = tmp + 1; *p; p++) {
+ if (*p == '/') {
+ *p = 0;
+ mkdir(tmp, S_IRWXU);
+ *p = '/';
+ }
+ }
+}
+
bool Slang::setOutput(const char* outputFile) {
std::string Error;
+ _mkdir_given_a_file(outputFile);
+
switch(mOutputType) {
case SlangCompilerOutput_Assembly:
case SlangCompilerOutput_LL: