diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-11-15 20:30:49 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-11-15 21:43:08 -0800 |
commit | 672c4091b5a43442759886144607aa407a04e5bc (patch) | |
tree | cda5dc54039f6c711d07aae8890f99269c499a42 | |
parent | f8747c4355f43b11489cc85eb8b5b922685fec39 (diff) | |
download | tmwa-672c4091b5a43442759886144607aa407a04e5bc.tar.gz tmwa-672c4091b5a43442759886144607aa407a04e5bc.tar.bz2 tmwa-672c4091b5a43442759886144607aa407a04e5bc.tar.xz tmwa-672c4091b5a43442759886144607aa407a04e5bc.zip |
Unbreak build
-rw-r--r-- | real.make | 2 | ||||
-rw-r--r-- | src/common/lock.cpp | 59 | ||||
-rw-r--r-- | src/common/lock.hpp | 17 | ||||
-rw-r--r-- | src/io/read.cpp | 2 | ||||
-rw-r--r-- | src/io/write.cpp | 2 |
5 files changed, 3 insertions, 79 deletions
@@ -245,7 +245,7 @@ obj/%.d: src/%.cpp set -o pipefail; \ ${CXX} ${CPPFLAGS} -DGENERATING_DEPENDENCIES ${CXXFLAGS} -MG -MP -MM $< \ -MT '$(patsubst %.d,%.ii,$@) $(patsubst %.d,%.ll,$@) $(patsubst %.d,%.bc,$@) $(patsubst %.d,%.s,$@) $(patsubst %.d,%.o,$@) $@' \ - | sed -e ':again; s:/[^/ ]*/../:/:; t again' \ + | sed -e ':again; s:/[^/ ]*/\.\./:/:; t again' \ -e 's: ${SRC_DIR}/: :g' \ > $@ endif diff --git a/src/common/lock.cpp b/src/common/lock.cpp deleted file mode 100644 index e21aee5..0000000 --- a/src/common/lock.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "lock.hpp" - -#include <unistd.h> - -#include <cstdio> - -#include "../strings/fstring.hpp" -#include "../strings/zstring.hpp" - -#include "cxxstdio.hpp" -#include "socket.hpp" - -#include "../poison.hpp" - -/// number of backups to keep -static -const int backup_count = 10; - -/// Protected file writing -/// (Until the file is closed, it keeps the old file) - -// Start writing a tmpfile -FILE *lock_fopen(ZString filename, int *info) -{ - FILE *fp; - int no = getpid(); - - // Get a filename that doesn't already exist - FString newfile; - do - { - newfile = STRPRINTF("%s_%d.tmp", filename, no++); - fp = fopen(newfile.c_str(), "wx"); - } - while (!fp); - *info = --no; - return fp; -} - -// Delete the old file and rename the new file -void lock_fclose(FILE *fp, ZString filename, int *info) -{ - if (fp) - { - fclose(fp); - int n = backup_count; - FString old_filename = STRPRINTF("%s.%d", filename, n); - while (--n) - { - FString newer_filename = STRPRINTF("%s.%d", filename, n); - rename(newer_filename.c_str(), old_filename.c_str()); - old_filename = std::move(newer_filename); - } - rename(filename.c_str(), old_filename.c_str()); - - FString tmpfile = STRPRINTF("%s_%d.tmp", filename, *info); - rename(tmpfile.c_str(), filename.c_str()); - } -} diff --git a/src/common/lock.hpp b/src/common/lock.hpp deleted file mode 100644 index 5ca1aed..0000000 --- a/src/common/lock.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LOCK_HPP -#define LOCK_HPP - -#include "sanity.hpp" - -#include <cstdio> - -#include "../strings/fwd.hpp" - -// TODO replace with a class - -/// Locked FILE I/O -// Changes are made in a separate file until lock_fclose -FILE *lock_fopen(ZString filename, int *info); -void lock_fclose(FILE *fp, ZString filename, int *info); - -#endif // LOCK_HPP diff --git a/src/io/read.cpp b/src/io/read.cpp index fad40bb..11a0020 100644 --- a/src/io/read.cpp +++ b/src/io/read.cpp @@ -27,7 +27,7 @@ #include "../common/cxxstdio.hpp" -#include "src/poison.hpp" +#include "../poison.hpp" namespace io diff --git a/src/io/write.cpp b/src/io/write.cpp index 5f8a975..67002e2 100644 --- a/src/io/write.cpp +++ b/src/io/write.cpp @@ -25,7 +25,7 @@ #include "../strings/xstring.hpp" -#include "src/poison.hpp" +#include "../poison.hpp" namespace io |