aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/indexers/fromfile.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libcrystfel/src/indexers/fromfile.c b/libcrystfel/src/indexers/fromfile.c
index aa2c8999..f39a717b 100644
--- a/libcrystfel/src/indexers/fromfile.c
+++ b/libcrystfel/src/indexers/fromfile.c
@@ -190,15 +190,26 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts)
return NULL;
}
- dp = malloc(sizeof(struct fromfile_private));
- if ( dp == NULL ) return NULL;
+ /* If filename is not absolute, jump out of working directory */
+ if ( opts->filename[0] == '/' ) {
+ fh = fopen(opts->filename, "r");
+ } else {
+ char *prefixed_fn = malloc(4+strlen(opts->filename));
+ if ( prefixed_fn == NULL ) return NULL;
+ strcpy(prefixed_fn, "../");
+ strcat(prefixed_fn, opts->filename);
+ fh = fopen(prefixed_fn, "r");
+ free(prefixed_fn);
+ }
- fh = fopen(opts->filename, "r");
if ( fh == NULL ) {
ERROR("Couldn't find solution file '%s'\n", opts->filename);
return NULL;
}
+ dp = malloc(sizeof(struct fromfile_private));
+ if ( dp == NULL ) return NULL;
+
dp->sol_hash = NULL;
/* Read indexing solutions */