summaryrefslogtreecommitdiff
path: root/navit/maptool/tempfile.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-06 23:05:01 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-06 23:05:01 +0000
commitf439b68fcbe86925ab968df3f01ea7931096bd42 (patch)
treede1f92057ca6d8206fb7324165517dc8085eab5d /navit/maptool/tempfile.c
parent18c4596dd1e20e7aeadd7d0cb4bdf460d09b63ea (diff)
downloadnavit-f439b68fcbe86925ab968df3f01ea7931096bd42.tar.gz
Add:Tools:Made osm2navit more modular and renamed to maptool
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2724 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/maptool/tempfile.c')
-rw-r--r--navit/maptool/tempfile.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/navit/maptool/tempfile.c b/navit/maptool/tempfile.c
new file mode 100644
index 000000000..e67dd766e
--- /dev/null
+++ b/navit/maptool/tempfile.c
@@ -0,0 +1,38 @@
+#include <unistd.h>
+#include "maptool.h"
+#include "debug.h"
+
+FILE *
+tempfile(char *suffix, char *name, int mode)
+{
+ char buffer[4096];
+ sprintf(buffer,"%s_%s.tmp",name, suffix);
+ switch (mode) {
+ case 0:
+ return fopen(buffer, "rb");
+ case 1:
+ return fopen(buffer, "wb+");
+ case 2:
+ return fopen(buffer, "ab");
+ default:
+ return NULL;
+ }
+}
+
+void
+tempfile_unlink(char *suffix, char *name)
+{
+ char buffer[4096];
+ sprintf(buffer,"%s_%s.tmp",name, suffix);
+ unlink(buffer);
+}
+
+void
+tempfile_rename(char *suffix, char *from, char *to)
+{
+ char buffer_from[4096],buffer_to[4096];
+ sprintf(buffer_from,"%s_%s.tmp",from,suffix);
+ sprintf(buffer_to,"%s_%s.tmp",to,suffix);
+ dbg_assert(rename(buffer_from, buffer_to) == 0);
+
+}