Mercurial > pidgin
comparison libpurple/util.c @ 20917:aa420b502a6b
nosnilmot points out that this is a better way to ensure the size is valid.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 13 Oct 2007 17:23:40 +0000 |
parents | e1f1f3c1c19c |
children | 4a8366502f01 5915ad785ee7 |
comparison
equal
deleted
inserted
replaced
20916:e1f1f3c1c19c | 20917:aa420b502a6b |
---|---|
2563 struct stat st; | 2563 struct stat st; |
2564 | 2564 |
2565 purple_debug_info("util", "Writing file %s\n", | 2565 purple_debug_info("util", "Writing file %s\n", |
2566 filename_full); | 2566 filename_full); |
2567 | 2567 |
2568 g_return_val_if_fail((size >= -1), FALSE); | |
2569 | |
2568 filename_temp = g_strdup_printf("%s.save", filename_full); | 2570 filename_temp = g_strdup_printf("%s.save", filename_full); |
2569 | 2571 |
2570 /* Remove an old temporary file, if one exists */ | 2572 /* Remove an old temporary file, if one exists */ |
2571 if (g_file_test(filename_temp, G_FILE_TEST_EXISTS)) | 2573 if (g_file_test(filename_temp, G_FILE_TEST_EXISTS)) |
2572 { | 2574 { |
2588 g_free(filename_temp); | 2590 g_free(filename_temp); |
2589 return FALSE; | 2591 return FALSE; |
2590 } | 2592 } |
2591 | 2593 |
2592 /* Write to file */ | 2594 /* Write to file */ |
2593 real_size = (size == -1) ? strlen(data) : size; | 2595 real_size = (size == -1) ? strlen(data) : (size_t) size; |
2594 byteswritten = fwrite(data, 1, real_size, file); | 2596 byteswritten = fwrite(data, 1, real_size, file); |
2595 | 2597 |
2596 /* Close file */ | 2598 /* Close file */ |
2597 if (fclose(file) != 0) | 2599 if (fclose(file) != 0) |
2598 { | 2600 { |