diff options
author | OBATA Akio <[email protected]> | 2019-10-24 10:16:37 +0900 |
---|---|---|
committer | monsta <[email protected]> | 2020-02-16 13:58:25 +0300 |
commit | ff39907c4fb9ec52f1fb33a650670e9c50de293c (patch) | |
tree | 1764773e7b7f2487e8f5a47a3f7284d8bde7a9dc | |
parent | fba8265a6bc5d36dfddfadd7a3d4545c2c4732b6 (diff) | |
download | mate-desktop-ff39907c4fb9ec52f1fb33a650670e9c50de293c.tar.bz2 mate-desktop-ff39907c4fb9ec52f1fb33a650670e9c50de293c.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 4ef0b52..c1ec81b 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; |