diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-04-01 18:01:26 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-04-01 18:01:26 +0000 |
commit | 506930a4e3e09276e1cf44f25820acc2e5f7f19f (patch) | |
tree | 3c718534412b0e37e4eba285d0ec7ac8fa64cf65 /src/cache.c | |
parent | 63affa283744195cd6bd3de6b9c45b2362b8b1b9 (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
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 13 |
1 files changed, 10 insertions, 3 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 |