zif-utils

zif-utils — Simple utility functions useful to zif

Synopsis

#define             ZIF_UTILS_ERROR
enum                ZifUtilsError;
#define             ZIF_PACKAGE_ID_NAME
#define             ZIF_PACKAGE_ID_VERSION
#define             ZIF_PACKAGE_ID_ARCH
#define             ZIF_PACKAGE_ID_DATA
gboolean            zif_init                            (void);
GQuark              zif_utils_error_quark               (void);
void                zif_list_print_array                (GPtrArray *array);
gchar *             zif_package_id_from_nevra           (const gchar *name,
                                                         guint epoch,
                                                         const gchar *version,
                                                         const gchar *release,
                                                         const gchar *arch,
                                                         const gchar *data);
gboolean            zif_boolean_from_text               (const gchar *text);
gint                zif_compare_evr                     (const gchar *a,
                                                         const gchar *b);
gboolean            zif_file_untar                      (const gchar *filename,
                                                         const gchar *directory,
                                                         GError **error);
gboolean            zif_file_decompress                 (const gchar *in,
                                                         const gchar *out,
                                                         ZifState *state,
                                                         GError **error);
gchar *             zif_file_get_uncompressed_name      (const gchar *filename);
gboolean            zif_file_is_compressed_name         (const gchar *filename);
gchar **            zif_package_id_split                (const gchar *package_id);
gboolean            zif_package_id_check                (const gchar *package_id);

Description

Common, non-object functions are declared here.

Details

ZIF_UTILS_ERROR

#define ZIF_UTILS_ERROR (zif_utils_error_quark ())


enum ZifUtilsError

typedef enum {
	ZIF_UTILS_ERROR_FAILED,
	ZIF_UTILS_ERROR_FAILED_TO_READ,
	ZIF_UTILS_ERROR_FAILED_TO_WRITE,
	ZIF_UTILS_ERROR_CANCELLED,
	ZIF_UTILS_ERROR_LAST
} ZifUtilsError;


ZIF_PACKAGE_ID_NAME

#define ZIF_PACKAGE_ID_NAME 0


ZIF_PACKAGE_ID_VERSION

#define ZIF_PACKAGE_ID_VERSION 1


ZIF_PACKAGE_ID_ARCH

#define ZIF_PACKAGE_ID_ARCH 2


ZIF_PACKAGE_ID_DATA

#define ZIF_PACKAGE_ID_DATA 3


zif_init ()

gboolean            zif_init                            (void);

This must be called before any of the zif_* functions are called.

Returns :

TRUE if we initialised correctly

Since 0.1.0


zif_utils_error_quark ()

GQuark              zif_utils_error_quark               (void);

Returns :

Our personal error quark.

Since 0.1.0


zif_list_print_array ()

void                zif_list_print_array                (GPtrArray *array);

Print an array of strings to STDOUT.

array :

The string array to print

Since 0.1.0


zif_package_id_from_nevra ()

gchar *             zif_package_id_from_nevra           (const gchar *name,
                                                         guint epoch,
                                                         const gchar *version,
                                                         const gchar *release,
                                                         const gchar *arch,
                                                         const gchar *data);

name :

epoch :

version :

release :

arch :

data :

Returns :


zif_boolean_from_text ()

gboolean            zif_boolean_from_text               (const gchar *text);

Convert a text boolean into it's enumerated boolean state

text :

the input text

Returns :

TRUE for positive, FALSE for negative

Since 0.1.0


zif_compare_evr ()

gint                zif_compare_evr                     (const gchar *a,
                                                         const gchar *b);

Compare two [epoch:]version[-release] strings

a :

the first version string

b :

the second version string

Returns :

1 for a>b, 0 for a==b, -1 for b>a

Since 0.1.0


zif_file_untar ()

gboolean            zif_file_untar                      (const gchar *filename,
                                                         const gchar *directory,
                                                         GError **error);

Untar files into a directory

filename :

the filename to unpack

directory :

the directory to unpack into

error :

a valid GError

Returns :

TRUE if the file was decompressed

Since 0.1.0


zif_file_decompress ()

gboolean            zif_file_decompress                 (const gchar *in,
                                                         const gchar *out,
                                                         ZifState *state,
                                                         GError **error);

Decompress files into a directory

in :

the filename to unpack

out :

the file to create

state :

a ZifState to use for progress reporting

error :

a valid GError

Returns :

TRUE if the file was decompressed

Since 0.1.0


zif_file_get_uncompressed_name ()

gchar *             zif_file_get_uncompressed_name      (const gchar *filename);

Finds the uncompressed filename.

filename :

the filename, e.g. /lib/dave.tar.gz

Returns :

the uncompressed file name, e.g. /lib/dave.tar, use g_free() to free.

Since 0.1.0


zif_file_is_compressed_name ()

gboolean            zif_file_is_compressed_name         (const gchar *filename);

Finds out if the filename is compressed

filename :

the filename, e.g. /lib/dave.tar.gz

Returns :

TRUE if the file needs decompression

Since 0.1.0


zif_package_id_split ()

gchar **            zif_package_id_split                (const gchar *package_id);

Splits a PackageID into the correct number of parts, checking the correct number of delimiters are present.

package_id :

the ; delimited PackageID to split

Returns :

a GStrv or NULL if invalid, use g_strfreev() to free

Since 0.1.0


zif_package_id_check ()

gboolean            zif_package_id_check                (const gchar *package_id);

package_id :

the PackageID to check

Returns :

TRUE if the PackageID was well formed.

Since 0.1.0