comparison src/log.c @ 13471:0f3036e073b6

[gaim-migrate @ 15847] Use a temp file in the same directory as the target index path. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 09 Mar 2006 01:17:33 +0000
parents e4aa2648ca28
children 660916251ba8
comparison
equal deleted inserted replaced
13470:f5bc36ecf8d0 13471:0f3036e073b6
1304 struct stat st; 1304 struct stat st;
1305 time_t log_last_modified; 1305 time_t log_last_modified;
1306 FILE *index; 1306 FILE *index;
1307 FILE *file; 1307 FILE *file;
1308 GError *error; 1308 GError *error;
1309 char *index_template;
1309 int index_fd; 1310 int index_fd;
1310 char *index_tmp; 1311 char *index_tmp;
1311 char buf[BUF_LONG]; 1312 char buf[BUF_LONG];
1312 struct tm tm; 1313 struct tm tm;
1313 char month[4]; 1314 char month[4];
1384 gaim_stringref_unref(pathref); 1385 gaim_stringref_unref(pathref);
1385 g_free(pathstr); 1386 g_free(pathstr);
1386 return NULL; 1387 return NULL;
1387 } 1388 }
1388 1389
1389 if ((index_fd = g_file_open_tmp(NULL, &index_tmp, &error)) == -1) { 1390 index_template = g_strdup_printf("%s.XXXXXX", pathstr);
1391 if ((index_fd = g_file_open_tmp(index_template, &index_tmp, &error)) == -1) {
1390 gaim_debug_error("log", "Failed to open index temp file: %s\n", 1392 gaim_debug_error("log", "Failed to open index temp file: %s\n",
1391 error->message); 1393 error->message);
1392 g_error_free(error); 1394 g_error_free(error);
1393 g_free(pathstr); 1395 g_free(pathstr);
1394 index = NULL; 1396 index = NULL;
1404 g_free(index_tmp); 1406 g_free(index_tmp);
1405 } 1407 }
1406 g_free(pathstr); 1408 g_free(pathstr);
1407 } 1409 }
1408 } 1410 }
1411 g_free(index_template);
1409 1412
1410 while (fgets(buf, BUF_LONG, file)) { 1413 while (fgets(buf, BUF_LONG, file)) {
1411 if ((newlog = strstr(buf, "---- New C"))) { 1414 if ((newlog = strstr(buf, "---- New C"))) {
1412 int length; 1415 int length;
1413 int offset; 1416 int offset;