aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-19 14:08:28 +0100
committerThomas White <taw@physics.org>2021-03-19 14:11:00 +0100
commit4084ac4ad8d745b12f97c9881e0fb50a0ac21da4 (patch)
tree249050cea3ac3c2735fbf05ded80f66d67c38aa1
parent42727512dc46459b349de68be835735ed26e186b (diff)
FromFile indexer: Take account of working directory
-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 */