diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-27 02:33:28 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-27 02:34:24 +0100 |
commit | 085f2d7eef0d77e06977d095927789bf948538a4 (patch) | |
tree | ba38258f577146505a7ec6850ddd0bbcaac95b5b /fastiv-io.c | |
parent | b97ac26cfb97377a2416f854fb07b12441d39c0b (diff) | |
download | fiv-085f2d7eef0d77e06977d095927789bf948538a4.tar.gz fiv-085f2d7eef0d77e06977d095927789bf948538a4.tar.xz fiv-085f2d7eef0d77e06977d095927789bf948538a4.zip |
Use GFile a bit more
Diffstat (limited to 'fastiv-io.c')
-rw-r--r-- | fastiv-io.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/fastiv-io.c b/fastiv-io.c index 13dfa9d..0e9b8c4 100644 --- a/fastiv-io.c +++ b/fastiv-io.c @@ -1365,21 +1365,23 @@ fail_init: } cairo_surface_t * -fastiv_io_lookup_thumbnail(const gchar *target, FastivIoThumbnailSize size) +fastiv_io_lookup_thumbnail(GFile *target, FastivIoThumbnailSize size) { g_return_val_if_fail(size >= FASTIV_IO_THUMBNAIL_SIZE_MIN && size <= FASTIV_IO_THUMBNAIL_SIZE_MAX, NULL); - GStatBuf st; - if (g_stat(target, &st)) + // Local files only, at least for now. + gchar *path = g_file_get_path(target); + if (!path) return NULL; - // TODO(p): Consider making the `target` an absolute path, if it isn't. - // Or maybe let it fail, and document the requirement. - gchar *uri = g_filename_to_uri(target, NULL, NULL); - if (!uri) + GStatBuf st = {}; + int err = g_stat(path, &st); + g_free(path); + if (err) return NULL; + gchar *uri = g_file_get_uri(target); gchar *sum = g_compute_checksum_for_string(G_CHECKSUM_MD5, uri, -1); gchar *cache_dir = get_xdg_home_dir("XDG_CACHE_HOME", ".cache"); |