Mercurial > pidgin
comparison libpurple/core.c @ 16691:f8f78fa7e774
Solicit bug reports
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 30 Apr 2007 04:39:13 +0000 |
parents | f9c369b4291c |
children | 176d0fc8bc16 |
comparison
equal
deleted
inserted
replaced
16690:1ffb8f6bd2bb | 16691:f8f78fa7e774 |
---|---|
283 #ifndef _WIN32 | 283 #ifndef _WIN32 |
284 char *old_name; | 284 char *old_name; |
285 #endif | 285 #endif |
286 if (g_rename(path, new_name)) | 286 if (g_rename(path, new_name)) |
287 { | 287 { |
288 purple_debug_error("core", "Error renaming %s to %s: %s\n", | 288 purple_debug_error("core", "Error renaming %s to %s: %s. Please report this at http://developer.pidgin.im\n", |
289 path, new_name, strerror(errno)); | 289 path, new_name, strerror(errno)); |
290 g_free(new_name); | 290 g_free(new_name); |
291 return FALSE; | 291 return FALSE; |
292 } | 292 } |
293 g_free(new_name); | 293 g_free(new_name); |
296 /* NOTE: This new_name is relative. */ | 296 /* NOTE: This new_name is relative. */ |
297 new_name = g_build_filename(relative, basename, NULL); | 297 new_name = g_build_filename(relative, basename, NULL); |
298 old_name = g_build_filename(old_base, basename, NULL); | 298 old_name = g_build_filename(old_base, basename, NULL); |
299 if (symlink(new_name, old_name)) | 299 if (symlink(new_name, old_name)) |
300 { | 300 { |
301 purple_debug_warning("core", "Error symlinking %s to %s: %s\n", | 301 purple_debug_warning("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\n", |
302 old_name, new_name, strerror(errno)); | 302 old_name, new_name, strerror(errno)); |
303 } | 303 } |
304 g_free(old_name); | 304 g_free(old_name); |
305 g_free(new_name); | 305 g_free(new_name); |
306 #endif | 306 #endif |
352 /* Ensure the user directory exists */ | 352 /* Ensure the user directory exists */ |
353 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR)) | 353 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR)) |
354 { | 354 { |
355 if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) | 355 if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) |
356 { | 356 { |
357 purple_debug_error("core", "Error creating directory %s: %s\n", | 357 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\n", |
358 user_dir, strerror(errno)); | 358 user_dir, strerror(errno)); |
359 g_free(status_file); | 359 g_free(status_file); |
360 g_free(old_user_dir); | 360 g_free(old_user_dir); |
361 return FALSE; | 361 return FALSE; |
362 } | 362 } |
364 | 364 |
365 /* This writes ~/.purple/migrating, which allows us to detect | 365 /* This writes ~/.purple/migrating, which allows us to detect |
366 * incomplete migrations and properly retry. */ | 366 * incomplete migrations and properly retry. */ |
367 if (!(fp = g_fopen(status_file, "w"))) | 367 if (!(fp = g_fopen(status_file, "w"))) |
368 { | 368 { |
369 purple_debug_error("core", "Error opening file %s for writing: %s\n", | 369 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\n", |
370 status_file, strerror(errno)); | 370 status_file, strerror(errno)); |
371 g_free(status_file); | 371 g_free(status_file); |
372 g_free(old_user_dir); | 372 g_free(old_user_dir); |
373 return FALSE; | 373 return FALSE; |
374 } | 374 } |
376 | 376 |
377 /* Open ~/.gaim so we can loop over its contents. */ | 377 /* Open ~/.gaim so we can loop over its contents. */ |
378 err = NULL; | 378 err = NULL; |
379 if (!(dir = g_dir_open(old_user_dir, 0, &err))) | 379 if (!(dir = g_dir_open(old_user_dir, 0, &err))) |
380 { | 380 { |
381 purple_debug_error("core", "Error opening directory %s: %s\n", | 381 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\n", |
382 status_file, | 382 status_file, |
383 (err ? err->message : "Unknown error")); | 383 (err ? err->message : "Unknown error")); |
384 if (err) | 384 if (err) |
385 g_error_free(err); | 385 g_error_free(err); |
386 g_free(status_file); | 386 g_free(status_file); |
403 char buf[MAXPATHLEN]; | 403 char buf[MAXPATHLEN]; |
404 size_t linklen; | 404 size_t linklen; |
405 | 405 |
406 if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) | 406 if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) |
407 { | 407 { |
408 purple_debug_error("core", "Error reading symlink %s: %s\n", | 408 purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\n", |
409 name, strerror(errno)); | 409 name, strerror(errno)); |
410 g_free(name); | 410 g_free(name); |
411 g_dir_close(dir); | 411 g_dir_close(dir); |
412 g_free(status_file); | 412 g_free(status_file); |
413 g_free(old_user_dir); | 413 g_free(old_user_dir); |
435 /* Relative links will most likely still be | 435 /* Relative links will most likely still be |
436 * valid from ~/.purple, though not it's not | 436 * valid from ~/.purple, though not it's not |
437 * guaranteed. Oh well. */ | 437 * guaranteed. Oh well. */ |
438 if (symlink(buf, logs_dir)) | 438 if (symlink(buf, logs_dir)) |
439 { | 439 { |
440 purple_debug_error("core", "Error symlinking %s to %s: %s\n", | 440 purple_debug_error("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\n", |
441 logs_dir, buf, strerror(errno)); | 441 logs_dir, buf, strerror(errno)); |
442 g_free(name); | 442 g_free(name); |
443 g_free(logs_dir); | 443 g_free(logs_dir); |
444 g_dir_close(dir); | 444 g_dir_close(dir); |
445 g_free(status_file); | 445 g_free(status_file); |
472 const char *icons_entry; | 472 const char *icons_entry; |
473 | 473 |
474 err = NULL; | 474 err = NULL; |
475 if (!(icons_dir = g_dir_open(name, 0, &err))) | 475 if (!(icons_dir = g_dir_open(name, 0, &err))) |
476 { | 476 { |
477 purple_debug_error("core", "Error opening directory %s: %s\n", | 477 purple_debug_error("core", "Error opening directory %s: %s. Please report this at http://developer.pidgin.im\n", |
478 name, | 478 name, |
479 (err ? err->message : "Unknown error")); | 479 (err ? err->message : "Unknown error")); |
480 if (err) | 480 if (err) |
481 g_error_free(err); | 481 g_error_free(err); |
482 g_free(name); | 482 g_free(name); |
490 /* Ensure the new icon directory exists */ | 490 /* Ensure the new icon directory exists */ |
491 if (!g_file_test(new_icons_dir, G_FILE_TEST_IS_DIR)) | 491 if (!g_file_test(new_icons_dir, G_FILE_TEST_IS_DIR)) |
492 { | 492 { |
493 if (g_mkdir(new_icons_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) | 493 if (g_mkdir(new_icons_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) |
494 { | 494 { |
495 purple_debug_error("core", "Error creating directory %s: %s\n", | 495 purple_debug_error("core", "Error creating directory %s: %s. Please report this at http://developer.pidgin.im\n", |
496 new_icons_dir, strerror(errno)); | 496 new_icons_dir, strerror(errno)); |
497 g_free(new_icons_dir); | 497 g_free(new_icons_dir); |
498 g_dir_close(icons_dir); | 498 g_dir_close(icons_dir); |
499 g_free(name); | 499 g_free(name); |
500 g_dir_close(dir); | 500 g_dir_close(dir); |
553 char *new_name; | 553 char *new_name; |
554 FILE *new_file; | 554 FILE *new_file; |
555 | 555 |
556 if (!(fp = g_fopen(name, "rb"))) | 556 if (!(fp = g_fopen(name, "rb"))) |
557 { | 557 { |
558 purple_debug_error("core", "Error opening file %s for reading: %s\n", | 558 purple_debug_error("core", "Error opening file %s for reading: %s. Please report this at http://developer.pidgin.im\n", |
559 name, strerror(errno)); | 559 name, strerror(errno)); |
560 g_free(name); | 560 g_free(name); |
561 g_dir_close(dir); | 561 g_dir_close(dir); |
562 g_free(status_file); | 562 g_free(status_file); |
563 g_free(old_user_dir); | 563 g_free(old_user_dir); |
565 } | 565 } |
566 | 566 |
567 new_name = g_build_filename(user_dir, entry, NULL); | 567 new_name = g_build_filename(user_dir, entry, NULL); |
568 if (!(new_file = g_fopen(new_name, "wb"))) | 568 if (!(new_file = g_fopen(new_name, "wb"))) |
569 { | 569 { |
570 purple_debug_error("core", "Error opening file %s for writing: %s\n", | 570 purple_debug_error("core", "Error opening file %s for writing: %s. Please report this at http://developer.pidgin.im\n", |
571 new_name, strerror(errno)); | 571 new_name, strerror(errno)); |
572 fclose(fp); | 572 fclose(fp); |
573 g_free(new_name); | 573 g_free(new_name); |
574 g_free(name); | 574 g_free(name); |
575 g_dir_close(dir); | 575 g_dir_close(dir); |
584 size_t size; | 584 size_t size; |
585 | 585 |
586 size = fread(buf, 1, sizeof(buf), fp); | 586 size = fread(buf, 1, sizeof(buf), fp); |
587 if (size != sizeof(buf) && !feof(fp)) | 587 if (size != sizeof(buf) && !feof(fp)) |
588 { | 588 { |
589 purple_debug_error("core", "Error reading %s: %s\n", | 589 purple_debug_error("core", "Error reading %s: %s. Please report this at http://developer.pidgin.im\n", |
590 name, strerror(errno)); | 590 name, strerror(errno)); |
591 fclose(new_file); | 591 fclose(new_file); |
592 fclose(fp); | 592 fclose(fp); |
593 g_free(new_name); | 593 g_free(new_name); |
594 g_free(name); | 594 g_free(name); |
598 return FALSE; | 598 return FALSE; |
599 } | 599 } |
600 | 600 |
601 if (!fwrite(buf, size, 1, new_file) && ferror(new_file) != 0) | 601 if (!fwrite(buf, size, 1, new_file) && ferror(new_file) != 0) |
602 { | 602 { |
603 purple_debug_error("core", "Error writing %s: %s\n", | 603 purple_debug_error("core", "Error writing %s: %s. Please report this at http://developer.pidgin.im\n", |
604 new_name, strerror(errno)); | 604 new_name, strerror(errno)); |
605 fclose(new_file); | 605 fclose(new_file); |
606 fclose(fp); | 606 fclose(fp); |
607 g_free(new_name); | 607 g_free(new_name); |
608 g_free(name); | 608 g_free(name); |
613 } | 613 } |
614 } | 614 } |
615 | 615 |
616 if (fclose(new_file)) | 616 if (fclose(new_file)) |
617 { | 617 { |
618 purple_debug_error("core", "Error writing: %s: %s\n", | 618 purple_debug_error("core", "Error writing: %s: %s. Please report this at http://developer.pidgin.im\n", |
619 new_name, strerror(errno)); | 619 new_name, strerror(errno)); |
620 } | 620 } |
621 if (fclose(fp)) | 621 if (fclose(fp)) |
622 { | 622 { |
623 purple_debug_warning("core", "Error closing %s: %s\n", | 623 purple_debug_warning("core", "Error closing %s: %s\n", |
632 } | 632 } |
633 | 633 |
634 /* The migration was successful, so delete the status file. */ | 634 /* The migration was successful, so delete the status file. */ |
635 if (g_unlink(status_file)) | 635 if (g_unlink(status_file)) |
636 { | 636 { |
637 purple_debug_error("core", "Error unlinking file %s: %s\n", | 637 purple_debug_error("core", "Error unlinking file %s: %s. Please report this at http://developer.pidgin.im\n", |
638 status_file, strerror(errno)); | 638 status_file, strerror(errno)); |
639 g_free(status_file); | 639 g_free(status_file); |
640 return FALSE; | 640 return FALSE; |
641 } | 641 } |
642 | 642 |