diff options
-rwxr-xr-x | SE.o | bin | 45864 -> 50976 bytes | |||
-rw-r--r-- | SavEdit.cpp | 14 | ||||
-rw-r--r-- | SavEdit.h | 1 |
3 files changed, 11 insertions, 4 deletions
Binary files differ diff --git a/SavEdit.cpp b/SavEdit.cpp index b8996ab..1052a22 100644 --- a/SavEdit.cpp +++ b/SavEdit.cpp @@ -1,6 +1,7 @@ #include <iostream> #include <fstream> #include <vector> +#include <ctime> #include "SavEdit.h" @@ -57,15 +58,15 @@ void SavEdit::read() void SavEdit::save(std::string fname) { /* - * This subroutine writes the binary - * file using the offset vector. + * Writes the binary file using the + * offset vector. */ std::ofstream bfs(fname, std::ios::out | std::ios::binary); if(!bfs) { - // TODO: Translate + subroutine needed. + // TODO: Translate + add subroutine needed. std::cout << "Cannot create file." << std::endl; exit(2); } @@ -82,7 +83,12 @@ void SavEdit::backup() * before editing. */ - save(getFilename() + ".BAK"); + // Generate backup file name + std::string backup_name = "." + getFilename() ".BAK-" + std::to_string(m_changes); + + save(backup_name); + + m_changes++; } int SavEdit::checksum() @@ -34,6 +34,7 @@ class SavEdit std::vector<int> mem; enum language{en_US=0, ie_gle=1, ja_jp=2}; int lang; + int m_changes = 0; }; #endif |