# HG changeset patch # User John Tsiombikas # Date 1419773196 -7200 # Node ID 701507c8238f0587bf259b550efbc764be0ac33f # Parent cc9e0d8590e24205e6d2baf4f22da93f982fc26b foo diff -r cc9e0d8590e2 -r 701507c8238f src/volume.cc --- a/src/volume.cc Sat Dec 27 06:32:28 2014 +0200 +++ b/src/volume.cc Sun Dec 28 15:26:36 2014 +0200 @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include "volume.h" @@ -80,18 +81,28 @@ bool VoxelVolume::load(const char *fname) { + char *prefix = (char*)alloca(strlen(fname) + 1); + strcpy(prefix, fname); + char *slash = strrchr(prefix, '/'); + if(slash) { + *slash = 0; + } else { + prefix = 0; + } + FILE *fp = fopen(fname, "r"); if(!fp) { fprintf(stderr, "failed to open file: %s: %s\n", fname, strerror(errno)); return false; } - char buf[512]; + char buf[256], path[300]; while(fgets(buf, sizeof buf, fp)) { char *line = strip_space(buf); + sprintf(path, "%s/%s", prefix, line); Image img; - if(!img.load(line)) { + if(!img.load(path)) { slices.clear(); return false; }