GIO Extensions

GIO Extensions — various extensions to GIO

Functions

Includes

#include <libxfce4util/libxfce4util.h>

Description

Common used functions for I/O that are not provided by the Glib library

Functions

xfce_g_file_metadata_is_supported ()

gboolean
xfce_g_file_metadata_is_supported (GFile *file);

Checks if GVFS-metadata is available for the file provided.

Parameters

file

a GFile.

 

Returns

TRUE is GVFS-metadata is supported, FALSE otherwise.

Since: 4.17


xfce_g_file_create_checksum ()

gchar *
xfce_g_file_create_checksum (GFile *file,
                             GCancellable *cancellable,
                             GError **error);

Generates an SHA-256 hash of the file . Utilizes g_compute_checksum_for_data() which is present since Glib 2.16.

Parameters

file

a GFile.

 

cancellable

optional GCancellable object, NULL to ignore.

[nullable]

error

a GError.

[nullable]

Returns

Checksum of the file . If file read fails, returns NULL. Free with g_free().

[transfer full][nullable]

Since: 4.17


xfce_g_file_set_trusted ()

gboolean
xfce_g_file_set_trusted (GFile *file,
                         gboolean is_trusted,
                         GCancellable *cancellable,
                         GError **error);

Sets the "safety flag" on if is_trusted .

Safety flag is a new concept introduced in XFCE 4.17. It is basically an additional execution flag stored in GVFS-metadata. Unlike the execution flag (+x), it is safe to assume that this flag did not come from foreign location (for example, by downloading an tar archive) and is set by user.

The checksum of the file is stored, and would be considered "on" only if checksum matches with the file on execution.

Parameters

file

a GFile.

 

is_trusted

TRUE if trusted, FALSE if not

 

cancellable

optional GCancellable object, NULL to ignore.

[nullable]

error

a GError.

[nullable]

Returns

TRUE on success, FALSE on error.

Since: 4.17


xfce_g_file_is_trusted ()

gboolean
xfce_g_file_is_trusted (GFile *file,
                        GCancellable *cancellable,
                        GError **error);

Compares the checksum stored in safety flag with the actual file. If it matches, it is considered safe.

Read the documentation of xfce_g_file_set_trusted() for details.

Parameters

file

a GFile.

 

cancellable

optional GCancellable object, NULL to ignore.

[nullable]

error

a GError.

[nullable]

Returns

TRUE if safety flag is verified or not supported. FALSE otherwise.

Since: 4.17