aboutsummaryrefslogtreecommitdiff
path: root/fiv-thumbnail.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-30 21:47:28 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-30 22:32:29 +0100
commit380ddd540bd93850e4df254200cba5b1fdf05cc6 (patch)
tree3730d9cc0b3150b9084b612014554ab39ace8b15 /fiv-thumbnail.c
parent8b232dc44464a70b53c3b6e1616de21b52e13e67 (diff)
downloadfiv-380ddd540bd93850e4df254200cba5b1fdf05cc6.tar.gz
fiv-380ddd540bd93850e4df254200cba5b1fdf05cc6.tar.xz
fiv-380ddd540bd93850e4df254200cba5b1fdf05cc6.zip
Convert all loading to use GFile
Now we're able to make use of GVfs, with some caveats.
Diffstat (limited to 'fiv-thumbnail.c')
-rw-r--r--fiv-thumbnail.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c
index 1d7ad2b..60df749 100644
--- a/fiv-thumbnail.c
+++ b/fiv-thumbnail.c
@@ -223,20 +223,17 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
max_size <= FIV_THUMBNAIL_SIZE_MAX, FALSE);
// Local files only, at least for now.
- gchar *path = g_file_get_path(target);
+ const gchar *path = g_file_peek_path(target);
if (!path)
return FALSE;
GMappedFile *mf = g_mapped_file_new(path, FALSE, error);
- if (!mf) {
- g_free(path);
+ if (!mf)
return FALSE;
- }
GStatBuf st = {};
if (g_stat(path, &st)) {
set_error(error, g_strerror(errno));
- g_free(path);
return FALSE;
}
@@ -246,7 +243,6 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
cairo_surface_t *surface = fiv_io_open_from_data(
g_mapped_file_get_contents(mf), filesize, path, sRGB, FALSE, error);
- g_free(path);
g_mapped_file_unref(mf);
if (sRGB)
fiv_io_profile_free(sRGB);
@@ -329,7 +325,12 @@ static cairo_surface_t *
read_wide_thumbnail(
const gchar *path, const gchar *uri, time_t mtime, GError **error)
{
- cairo_surface_t *surface = fiv_io_open(path, NULL, FALSE, error);
+ gchar *thumbnail_uri = g_filename_to_uri(path, NULL, error);
+ if (!thumbnail_uri)
+ return NULL;
+
+ cairo_surface_t *surface = fiv_io_open(thumbnail_uri, NULL, FALSE, error);
+ g_free(thumbnail_uri);
if (!surface)
return NULL;
@@ -496,14 +497,9 @@ fiv_thumbnail_lookup(GFile *target, FivThumbnailSize size)
size <= FIV_THUMBNAIL_SIZE_MAX, NULL);
// Local files only, at least for now.
- gchar *path = g_file_get_path(target);
- if (!path)
- return NULL;
-
GStatBuf st = {};
- int err = g_stat(path, &st);
- g_free(path);
- if (err)
+ const gchar *path = g_file_peek_path(target);
+ if (!path || g_stat(path, &st))
return NULL;
gchar *uri = g_file_get_uri(target);