AscUnit

AscUnit — A data source unit (package, bundle, database, ...) for AscCompose to process

Functions

Types and Values

#define ASC_TYPE_UNIT
struct AscUnitClass
  AscUnit

Includes

#include <appstream-compose.h>

Description

Functions

asc_unit_new ()

AscUnit *
asc_unit_new (void);

Creates a new AscUnit.


asc_unit_get_bundle_kind ()

AsBundleKind
asc_unit_get_bundle_kind (AscUnit *unit);

Gets the bundle kind of this unit.

Parameters

unit

an AscUnit instance.

 

asc_unit_set_bundle_kind ()

void
asc_unit_set_bundle_kind (AscUnit *unit,
                          AsBundleKind kind);

Sets the kind of the bundle this unit represents.

Parameters

unit

an AscUnit instance.

 

asc_unit_get_bundle_id ()

const gchar *
asc_unit_get_bundle_id (AscUnit *unit);

Gets the ID name of the bundle (a package / Flatpak / any entity containing metadata) that this unit represents.

Parameters

unit

an AscUnit instance.

 

asc_unit_get_bundle_id_safe ()

const gchar *
asc_unit_get_bundle_id_safe (AscUnit *unit);

Gets the ID name of the bundle, normalized to be safe to use in filenames. This may *not* be the same name as set via asc_unit_get_bundle_id()

Parameters

unit

an AscUnit instance.

 

asc_unit_set_bundle_id ()

void
asc_unit_set_bundle_id (AscUnit *unit,
                        const gchar *id);

Sets the ID of the bundle represented by this unit.

Parameters

unit

an AscUnit instance.

 

id

The new ID.

 

asc_unit_get_contents ()

GPtrArray *
asc_unit_get_contents (AscUnit *unit);

Get a list of all files contained by this unit.

Parameters

unit

an AscUnit instance.

 

Returns

(transfer none) (element-type utf8) : A file listing


asc_unit_set_contents ()

void
asc_unit_set_contents (AscUnit *unit,
                       GPtrArray *contents);

Set list of files this unit contains.

Parameters

unit

an AscUnit instance.

 

contents

A list of files contained by this unit.

[element-type utf8]

asc_unit_get_relevant_paths ()

GPtrArray *
asc_unit_get_relevant_paths (AscUnit *unit);

Get a list of paths that are relevant for data processing.

Parameters

unit

an AscUnit instance.

 

Returns

(transfer none) (element-type utf8) : A list of paths


asc_unit_add_relevant_path ()

void
asc_unit_add_relevant_path (AscUnit *unit,
                            const gchar *path);

Add a path to the list of relevant directories. A unit may only read data in paths that were previously registered as relevant.

Parameters

unit

an AscUnit instance.

 

path

path to be considered relevant

 

asc_unit_open ()

gboolean
asc_unit_open (AscUnit *unit,
               GError **error);

Open this unit, populating its content listing.

Parameters

unit

an AscUnit instance.

 

error

A GError

 

asc_unit_close ()

void
asc_unit_close (AscUnit *unit);

Close this unit, possibly freeing its resources. Calls to read_data() or get_contents() may not produce results until open() is called again.

Parameters

unit

an AscUnit instance.

 

asc_unit_file_exists ()

gboolean
asc_unit_file_exists (AscUnit *unit,
                      const gchar *filename);

Returns TRUE if the filename exists and is readable using asc_unit_read_data.

Parameters

unit

an AscUnit instance.

 

filename

The filename to check.

 

asc_unit_dir_exists ()

gboolean
asc_unit_dir_exists (AscUnit *unit,
                     const gchar *dirname);

Returns TRUE if the directory exists and files in it are readable.

Parameters

unit

an AscUnit instance.

 

dirname

The directory name to check.

 

asc_unit_read_data ()

GBytes *
asc_unit_read_data (AscUnit *unit,
                    const gchar *filename,
                    GError **error);

Read the contents of the selected file into memory and return them.

Parameters

unit

an AscUnit instance.

 

filename

The file to read data for.

 

error

A GError

 

asc_unit_get_user_data ()

gpointer
asc_unit_get_user_data (AscUnit *unit);

Get user-defined data. This is a helper function for bindings.

Parameters

unit

an AscUnit instance.

 

asc_unit_set_user_data ()

void
asc_unit_set_user_data (AscUnit *unit,
                        gpointer user_data);

Assign user-defined data to this object. This is a helper function for bindings.

Parameters

unit

an AscUnit instance.

 

user_data

the user data

 

Types and Values

ASC_TYPE_UNIT

#define ASC_TYPE_UNIT (asc_unit_get_type ())

struct AscUnitClass

struct AscUnitClass {
	GObjectClass parent_class;

	gboolean (*open) (AscUnit *unit,
			  GError **error);
	void (*close) (AscUnit *unit);

	gboolean (*file_exists) (AscUnit *unit,
				  const gchar *filename);
	gboolean (*dir_exists) (AscUnit *unit,
				  const gchar *dirname);
	GBytes *(*read_data) (AscUnit *unit,
			      const gchar *filename,
			      GError **error);
};

AscUnit

typedef struct _AscUnit AscUnit;