aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-04-01 18:01:26 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-04-01 18:01:26 +0000
commit506930a4e3e09276e1cf44f25820acc2e5f7f19f (patch)
tree3c718534412b0e37e4eba285d0ec7ac8fa64cf65
parent63affa283744195cd6bd3de6b9c45b2362b8b1b9 (diff)
Choose a proper filename for the reflection cache file
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@22 bf6ca9ba-c028-0410-8290-897cf20841d1
-rw-r--r--src/cache.c13
-rw-r--r--src/main.c5
2 files changed, 12 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c
index f1998b7..99975c6 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -53,7 +53,7 @@ ReflectionContext *cache_load(const char *filename) {
return rctx;
}
-int cache_save(const char *filename, ReflectionContext *rctx) {
+int cache_save(const char *input_filename, ReflectionContext *rctx) {
FILE *f;
CacheHeader ch;
@@ -61,7 +61,13 @@ int cache_save(const char *filename, ReflectionContext *rctx) {
int count;
const char top[16] = "DTRCACHE\0\0\0\0\0\0\0\0";
size_t cachedreflection_size;
-
+ char *cache_filename;
+
+ cache_filename = malloc(strlen(input_filename)+7);
+ strcpy(cache_filename, ctx->filename);
+ strcat(cache_filename, ".cache");
+ printf("Caching reflections to %s\n", cache_filename);
+
cachedreflection_size = sizeof(Reflection) - sizeof(Reflection *);
count = 0;
@@ -71,7 +77,8 @@ int cache_save(const char *filename, ReflectionContext *rctx) {
r = r->next;
};
- f = fopen(filename, "wb");
+ f = fopen(cache_filename, "wb");
+ free(cache_filename);
memcpy(&ch.top, &top, sizeof(top));
ch.count = count;
ch.scale = 0.; //temp, currently doesn't do anything
diff --git a/src/main.c b/src/main.c
index 681165a..c3155d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,8 +66,7 @@ static gint main_method_window_response(GtkWidget *method_window, gint response,
}
if ( ctx->inputfiletype != INPUT_CACHE ) {
- printf("Saving reflection block to reflect.cache\n");
- cache_save("reflect.cache", ctx->reflectionctx);
+ cache_save(ctx->filename, ctx->reflectionctx);
}
if ( !val && (ctx->rmode == RECONSTRUCTION_PREDICTION) ) {
@@ -182,7 +181,7 @@ int main(int argc, char *argv[]) {
printf("MRC tomography file detected.\n");
ctx->inputfiletype = INPUT_MRC;
} else if ( cache_is_cachefile(filename) ) {
- printf("reflect.cache detected.\n");
+ printf("Cached reflection file detected.\n");
ctx->inputfiletype = INPUT_CACHE;
} else {
fprintf(stderr, "Unrecognised input file type\n");