From 9e71296d22207988e0e3986591f95f6ea04dae75 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 28 May 2014 10:31:39 +0200 Subject: Clarify code and fix 64bit warning. --- src/file.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/file.cc b/src/file.cc index 7c4725d..9d86c1c 100644 --- a/src/file.cc +++ b/src/file.cc @@ -68,11 +68,15 @@ File::File(const char *fn, const char* ext, Info *i) seqnum = 0; fd = -1; - int pos = (int)strrchr(filename, '/'); + char *cpos = strrchr(filename, '/'); memset(path, 0, sizeof(path)); - if(pos) { // pos is NULL, a file will be created in the current dir (Which is bad) - pos -= (int)filename; // Make pos relative to the beginning of the string + // cpos is NULL, a file will be created in the current dir (Which is bad) + if(cpos) { + + // Make pos relative to the beginning of the string + size_t pos = (size_t)(cpos - filename); + strncpy(path, filename, pos); createPath(path); } -- cgit v1.2.3