Commit 1597e17d authored by Ell's avatar Ell

buffer: add gegl_buffer_swap_has_file()

... which checks if a given file is a swap file, that is, if it has
been created with gegl_buffer_swap_create_file(), and hasn't been
removed yet.
parent 1ee31231
......@@ -174,6 +174,22 @@ gegl_buffer_swap_remove_file (const gchar *path)
g_warning ("attempt to remove unregistered swap file '%s'", path);
}
gboolean
gegl_buffer_swap_has_file (const gchar *path)
{
gboolean found;
g_return_val_if_fail (path != NULL, FALSE);
g_mutex_lock (&swap_mutex);
found = (g_hash_table_lookup (swap_files, path) != NULL);
g_mutex_unlock (&swap_mutex);
return found;
}
/* private functions */
......
......@@ -37,7 +37,7 @@ G_BEGIN_DECLS
* file path, or %NULL is the swap is disabled. The returned string
* should be freed with g_free() when no longer needed.
*/
gchar * gegl_buffer_swap_create_file (const gchar *suffix);
gchar * gegl_buffer_swap_create_file (const gchar *suffix);
/**
* gegl_buffer_swap_remove_file:
......@@ -47,7 +47,17 @@ gchar * gegl_buffer_swap_create_file (const gchar *suffix);
* Removes a swap file, generated using gegl_buffer_swap_create_file(),
* unlinking the file, if exists.
*/
void gegl_buffer_swap_remove_file (const gchar *path);
void gegl_buffer_swap_remove_file (const gchar *path);
/**
* gegl_buffer_swap_has_file:
* @path: (type filename): a filename
*
* Tests if @path is a swap file, that is, if it has been created
* with gegl_buffer_swap_create_file(), and hasn't been removed
* yet.
*/
gboolean gegl_buffer_swap_has_file (const gchar *path);
G_END_DECLS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment