summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-11-06 21:14:09 -0800
committerOri Bernstein <ori@eigenstate.org>2018-11-06 21:14:09 -0800
commit0556b63c0c444d2d77b270c7d51beb7e94f0d30a (patch)
tree38a687d669e54b7d783cee0f7a317653ab9fbfe3 /6
parent16c6e1242f50320bf8531e979bcb75ecfe88f9b5 (diff)
downloadmc-0556b63c0c444d2d77b270c7d51beb7e94f0d30a.tar.gz
Create the output directory when assembling.
Easier to bootstrap.
Diffstat (limited to '6')
-rw-r--r--6/main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/6/main.c b/6/main.c
index b770222..e699f3f 100644
--- a/6/main.c
+++ b/6/main.c
@@ -70,8 +70,8 @@ static void
assemble(char *asmsrc, char *path)
{
char *asmcmd[] = Asmcmd;
- char objfile[1024];
- char *psuffix;
+ char objfile[256], dirpath[256];
+ char *psuffix, *e;
char **p, **cmd;
size_t ncmd, i;
int pid, status;
@@ -88,6 +88,13 @@ assemble(char *asmsrc, char *path)
else
swapsuffix(objfile + i, sizeof objfile - i, path, ".myr", Objsuffix);
}
+ e = objfile;
+ while ((e = strstr(e, "/")) != NULL) {
+ memcpy(dirpath, objfile, (e - objfile));
+ mkdir(dirpath, 0755);
+ e++;
+ }
+
cmd = NULL;
ncmd = 0;
for (p = asmcmd; *p != NULL; p++)
@@ -184,7 +191,7 @@ genuse(char *path)
}
f = fopen(buf, "w");
if (!f) {
- fprintf(stderr, "Could not open path %s\n", buf);
+ fprintf(stderr, "could not open path %s\n", buf);
exit(1);
}
writeuse(f, file);