summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/file.cc10
1 files 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);
}