ResourceHelper

1. Overview

The ResourceHelper module provides application resource resolution for BastionGuard Backup. It locates GResource URIs and filesystem assets across packaged, system, user, environment-defined, and source-tree locations.

The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.


2. Dependencies and Integration

The module imports:

  • GLib
  • Gee

Key runtime integrations include:

  • Gee – typed lists, maps, queues, or collection operations
  • GIO/GLib streams – filesystem and process I/O

3. Declared Types

3.1 ResourceHelper

public class ResourceHelper : GLib.Object

This class encapsulates the state and operations described by this source file.


4. State, Properties, Constants, and Signals

The file does not maintain mutable object state. Its primary content is constants or stateless helper behavior.


5. Public API and Operational Methods

5.1 resource_prefix()

public static string resource_prefix()

Implements the resource prefix operation for this module.

5.2 resource_uri()

public static string resource_uri(string rel)

Implements the resource uri operation for this module.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.
  • Catches runtime errors locally and reports them through the logging layer or return value.

5.3 resource_exists()

public static bool resource_exists(string rel)

Implements the resource exists operation for this module.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.
  • Catches runtime errors locally and reports them through the logging layer or return value.

5.4 base_dirs()

public static Gee.ArrayList<string> base_dirs()

Returns the ordered asset search roots, including environment overrides, system data directories, user data directories, and source-tree development paths.

5.5 resolve_file()

public static string? resolve_file(string rel)

Implements the resolve file operation for this module.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

5.6 resolve_css()

public static string? resolve_css(string name)

Implements the resolve css operation for this module.

5.7 resolve_icon_file()

public static string? resolve_icon_file(string icon_name)

Implements the resolve icon file operation for this module.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

6. Filesystem Paths and Resource Locations

The source references the following absolute or template paths:

/org/bastionguard/backup
/usr/local/share/BastionGuard/data
/usr/local/share/bastionguard-backup
/usr/local/share/bastionguard-backup/images
/usr/local/share/icons/hicolor/128x128/apps
/usr/local/share/pixmaps
/usr/share/BastionGuard/data
/usr/share/bastionguard-backup
/usr/share/bastionguard-backup/images
/usr/share/icons/hicolor/128x128/apps
/usr/share/icons/hicolor/16x16/apps
/usr/share/icons/hicolor/22x22/apps
/usr/share/icons/hicolor/24x24/apps
/usr/share/icons/hicolor/32x32/apps
/usr/share/icons/hicolor/48x48/apps
/usr/share/icons/hicolor/64x64/apps
/usr/share/icons/hicolor/96x96/apps
/usr/share/pixmaps

Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.


7. Operational Flow

  1. Expose the module data or constant text to the caller.

8. Error Handling and Diagnostics

  • GLib and filesystem exceptions are caught locally in the operations that can fail.
  • Boolean, nullable, or empty-string return values communicate recoverable failures to callers.

9. Runtime and Security Considerations

  • Shared state: static caches and global switches are shared by all callers and are not automatically thread-isolated.

10. Licensing

The source is distributed under the license terms declared in the source header.