diff options
author | OBATA Akio <[email protected]> | 2019-10-24 10:16:37 +0900 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2019-10-31 11:18:15 -0400 |
commit | eea68481bab160e55f5e4d6e61d5a0a8d5a13d99 (patch) | |
tree | 66485f30450937f4ff3ebe8ebb92828128f00acd | |
parent | 066a7b1974e68db56eb86b59f758ef5580473480 (diff) | |
download | mate-desktop-eea68481bab160e55f5e4d6e61d5a0a8d5a13d99.tar.bz2 mate-desktop-eea68481bab160e55f5e4d6e61d5a0a8d5a13d99.tar.xz |
Treat time_t as gint64 to convert from/to string
"time_t" may not equal with "long", especiall 32-bit
platforms resolved "Year 2038 problem".
There are no standard way to convert time_t from/to
string, but GLib2 using gint64 type as a time internally,
so it is reasonable to use gint64 for such purpose.
-rw-r--r-- | libmate-desktop/mate-desktop-thumbnail.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libmate-desktop/mate-desktop-thumbnail.c b/libmate-desktop/mate-desktop-thumbnail.c index b874070..20da048 100644 --- a/libmate-desktop/mate-desktop-thumbnail.c +++ b/libmate-desktop/mate-desktop-thumbnail.c @@ -1398,7 +1398,7 @@ mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *fact char *tmp_path; const char *width, *height; int tmp_fd; - char mtime_str[21]; + gchar *mtime_str; gboolean saved_ok; GChecksum *checksum; guint8 digest[16]; @@ -1443,7 +1443,7 @@ mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *fact } close (tmp_fd); - g_snprintf (mtime_str, 21, "%ld", original_mtime); + mtime_str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)original_mtime); width = gdk_pixbuf_get_option (thumbnail, "tEXt::Thumb::Image::Width"); height = gdk_pixbuf_get_option (thumbnail, "tEXt::Thumb::Image::Height"); @@ -1481,6 +1481,7 @@ mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *fact g_clear_error (&error); } + g_free (mtime_str); g_free (path); g_free (tmp_path); } @@ -1506,7 +1507,7 @@ mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFact char *path, *file; char *tmp_path; int tmp_fd; - char mtime_str[21]; + gchar *mtime_str; gboolean saved_ok; GdkPixbuf *pixbuf; GChecksum *checksum; @@ -1549,7 +1550,7 @@ mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFact } close (tmp_fd); - g_snprintf (mtime_str, 21, "%ld", mtime); + mtime_str = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64)mtime); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); saved_ok = gdk_pixbuf_save (pixbuf, tmp_path, @@ -1559,6 +1560,7 @@ mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFact "tEXt::Software", "MATE::ThumbnailFactory", NULL); g_object_unref (pixbuf); + g_free (mtime_str); if (saved_ok) { g_chmod (tmp_path, 0600); @@ -1677,7 +1679,7 @@ mate_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime"); if (!thumb_mtime_str) return FALSE; - thumb_mtime = atol (thumb_mtime_str); + thumb_mtime = (time_t)g_ascii_strtoll (thumb_mtime_str, (gchar**)NULL, 10); if (mtime != thumb_mtime) return FALSE; |