/[zanavi_public1]/navit/navit/maptool/tempfile.c
ZANavi

Diff of /navit/navit/maptool/tempfile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 35 Revision 36
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the 15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19#define _FILE_OFFSET_BITS 64
20#define _LARGEFILE_SOURCE
21#define _LARGEFILE64_SOURCE
19#include <unistd.h> 22#include <unistd.h>
20#include "maptool.h" 23#include "maptool.h"
21#include "debug.h" 24#include "debug.h"
22 25
23char * 26char *
24tempfile_name(char *suffix, char *name) 27tempfile_name(char *suffix, char *name)
25{ 28{
26 return g_strdup_printf("%s_%s.tmp",name, suffix); 29 return g_strdup_printf("%s_%s.tmp",name, suffix);
27} 30}
31
28FILE * 32FILE *
29tempfile(char *suffix, char *name, int mode) 33tempfile(char *suffix, char *name, int mode)
30{ 34{
31 char *buffer=tempfile_name(suffix, name); 35 char *buffer=tempfile_name(suffix, name);
32 FILE *ret=NULL; 36 FILE *ret=NULL;
39 break; 43 break;
40 case 2: 44 case 2:
41 ret=fopen(buffer, "ab"); 45 ret=fopen(buffer, "ab");
42 break; 46 break;
43 } 47 }
48
49 if (debug_itembin(6))
50 {
51 fprintf(stderr,"== tempfile == open == FILENAME: %s FILEPOINTER: %p ==\n",buffer,ret);
52 }
44 g_free(buffer); 53 g_free(buffer);
54
45 return ret; 55 return ret;
46} 56}
47 57
48void 58void
49tempfile_unlink(char *suffix, char *name) 59tempfile_unlink(char *suffix, char *name)
58{ 68{
59 char buffer_from[4096],buffer_to[4096]; 69 char buffer_from[4096],buffer_to[4096];
60 sprintf(buffer_from,"%s_%s.tmp",from,suffix); 70 sprintf(buffer_from,"%s_%s.tmp",from,suffix);
61 sprintf(buffer_to,"%s_%s.tmp",to,suffix); 71 sprintf(buffer_to,"%s_%s.tmp",to,suffix);
62 dbg_assert(rename(buffer_from, buffer_to) == 0); 72 dbg_assert(rename(buffer_from, buffer_to) == 0);
63
64} 73}
74

Legend:
Removed from v.35  
changed lines
  Added in v.36

   
Visit the ZANavi Wiki