From e369f3e41590523b2662093d221f807c624c0288 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 28 Jan 2015 14:42:28 +0100 Subject: [PATCH] move backup() --- source/src/stream.cpp | 8 ++++++++ source/src/tools.h | 1 + source/src/worldio.cpp | 8 -------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/src/stream.cpp b/source/src/stream.cpp index e28ac085..363efc53 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -307,6 +307,14 @@ bool delfile(const char *path) return !remove(path); } +void backup(char *name, char *backupname) +{ + string backupfile; + copystring(backupfile, findfile(backupname, "wb")); + remove(backupfile); + rename(findfile(name, "wb"), backupfile); +} + #ifndef STANDALONE static int rwopsseek(SDL_RWops *rw, int offset, int whence) { diff --git a/source/src/tools.h b/source/src/tools.h index 71f47379..e8a61901 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -965,6 +965,7 @@ extern bool listdir(const char *dir, const char *ext, vector &files); extern int listfiles(const char *dir, const char *ext, vector &files); extern int listzipfiles(const char *dir, const char *ext, vector &files); extern bool delfile(const char *path); +extern void backup(char *name, char *backupname); extern bool addzip(const char *name, const char *mount = NULL, const char *strip = NULL, bool extract = false, int type = -1); extern bool removezip(const char *name); extern struct mapstats *loadmapstats(const char *filename, bool getlayout); diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index ae42cba6..97868f03 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -5,14 +5,6 @@ #define DEBUGCOND (worldiodebug==1) VARP(worldiodebug, 0, 0, 1); -void backup(char *name, char *backupname) -{ - string backupfile; - copystring(backupfile, findfile(backupname, "wb")); - remove(backupfile); - rename(findfile(name, "wb"), backupfile); -} - static string cgzname, ocgzname, bakname, cbakname, pcfname, mcfname, omcfname, mapname; const char *setnames(const char *name)