diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-29 23:23:43 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-01 15:19:45 -0700 |
commit | 3b98f3439e33b15bba2036c402f9925340fdb2b9 (patch) | |
tree | f6a59330bb747d9cc64f5f83d06e7f76dc01d540 /src/common/lock.cpp | |
parent | 8d1480c1be7c9741876d89008277a2b3629a4d01 (diff) | |
download | tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.gz tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.bz2 tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.xz tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.zip |
Poison std::string and use the various string classes
Diffstat (limited to 'src/common/lock.cpp')
-rw-r--r-- | src/common/lock.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/common/lock.cpp b/src/common/lock.cpp index 82856e1..f19cd92 100644 --- a/src/common/lock.cpp +++ b/src/common/lock.cpp @@ -17,17 +17,17 @@ const int backup_count = 10; /// (Until the file is closed, it keeps the old file) // Start writing a tmpfile -FILE *lock_fopen(const char *filename, int *info) +FILE *lock_fopen(ZString filename, int *info) { FILE *fp; int no = getpid(); // Get a filename that doesn't already exist - std::string newfile; + FString newfile; do { newfile = STRPRINTF("%s_%d.tmp", filename, no++); - fp = fopen_(newfile.c_str(), "wx"); + fp = fopen(newfile.c_str(), "wx"); } while (!fp); *info = --no; @@ -35,22 +35,22 @@ FILE *lock_fopen(const char *filename, int *info) } // Delete the old file and rename the new file -void lock_fclose(FILE *fp, const char *filename, int *info) +void lock_fclose(FILE *fp, ZString filename, int *info) { if (fp) { - fclose_(fp); + fclose(fp); int n = backup_count; - std::string old_filename = STRPRINTF("%s.%d", filename, n); + FString old_filename = STRPRINTF("%s.%d", filename, n); while (--n) { - std::string newer_filename = STRPRINTF("%s.%d", filename, 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, old_filename.c_str()); + rename(filename.c_str(), old_filename.c_str()); - std::string tmpfile = STRPRINTF("%s_%d.tmp", filename, *info); - rename(tmpfile.c_str(), filename); + FString tmpfile = STRPRINTF("%s_%d.tmp", filename, *info); + rename(tmpfile.c_str(), filename.c_str()); } } |