Commit 3e84c221 authored by Martin Uecker's avatar Martin Uecker

join: append to non-existing file

parent 807ac4b2
......@@ -11,6 +11,7 @@
#include <stdbool.h>
#include <complex.h>
#include <string.h>
#include <unistd.h>
#include "num/multind.h"
#include "num/init.h"
......@@ -61,7 +62,28 @@ int main_join(int argc, char* argv[])
count += 1;
// FIXME: check for cfl file
assert(count > 1);
int len = strlen(argv[argc - 1]);
char buf[len + 5];
strcpy(buf, argv[argc - 1]);
strcat(buf, ".cfl");
if (-1 == access(buf, F_OK)) {
// make sure we do not have any other file format
strcpy(buf, argv[argc - 1]);
strcat(buf, ".coo");
assert(-1 == access(buf, F_OK));
strcpy(buf, argv[argc - 1]);
strcat(buf, ".ra");
assert(-1 == access(buf, F_OK));
count--;
append = false;
}
}
long in_dims[count][N];
......
......@@ -15,10 +15,21 @@ tests/test-join-append: ones zeros join nrmse
$(TOOLDIR)/zeros 3 6 7 1 z ;\
$(TOOLDIR)/join 2 o z o j ;\
$(TOOLDIR)/join -a 2 z o o ;\
$(TOOLDIR)/nrmse -t 0.00001 o j ;\
$(TOOLDIR)/nrmse -t 0.00001 j o ;\
rm *.cfl ; rm *.hdr ; cd .. ; rmdir $(TESTS_TMP)
touch $@
TESTS += tests/test-join tests/test-join-append
tests/test-join-append-one: ones zeros join nrmse
set -e; mkdir $(TESTS_TMP) ; cd $(TESTS_TMP) ;\
$(TOOLDIR)/ones 3 6 7 1 o ;\
$(TOOLDIR)/zeros 3 6 7 1 z ;\
$(TOOLDIR)/join 2 o z j ;\
$(TOOLDIR)/join -a 2 o z x ;\
$(TOOLDIR)/nrmse -t 0.00001 j x ;\
rm *.cfl ; rm *.hdr ; cd .. ; rmdir $(TESTS_TMP)
touch $@
TESTS += tests/test-join tests/test-join-append tests/test-join-append-one
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment