1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: Alexander Larsson <alexl@redhat.com>
21 */
22
23#ifndef __G_RESOURCE_H__
24#define __G_RESOURCE_H__
25
26#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27#error "Only <gio/gio.h> can be included directly."
28#endif
29
30#include <gio/giotypes.h>
31
32G_BEGIN_DECLS
33
34/**
35 * G_TYPE_RESOURCE:
36 *
37 * The #GType for #GResource.
38 */
39#define G_TYPE_RESOURCE (g_resource_get_type ())
40
41
42/**
43 * G_RESOURCE_ERROR:
44 *
45 * Error domain for #GResource. Errors in this domain will be from the
46 * #GResourceError enumeration. See #GError for more information on
47 * error domains.
48 */
49#define G_RESOURCE_ERROR (g_resource_error_quark ())
50GIO_AVAILABLE_IN_2_32
51GQuark g_resource_error_quark (void);
52
53typedef struct _GStaticResource GStaticResource;
54
55struct _GStaticResource {
56 /*< private >*/
57 const guint8 *data;
58 gsize data_len;
59 GResource *resource;
60 GStaticResource *next;
61 gpointer padding;
62};
63
64GIO_AVAILABLE_IN_2_32
65GType g_resource_get_type (void) G_GNUC_CONST;
66GIO_AVAILABLE_IN_2_32
67GResource * g_resource_new_from_data (GBytes *data,
68 GError **error);
69GIO_AVAILABLE_IN_2_32
70GResource * g_resource_ref (GResource *resource);
71GIO_AVAILABLE_IN_2_32
72void g_resource_unref (GResource *resource);
73GIO_AVAILABLE_IN_2_32
74GResource * g_resource_load (const gchar *filename,
75 GError **error);
76GIO_AVAILABLE_IN_2_32
77GInputStream *g_resource_open_stream (GResource *resource,
78 const char *path,
79 GResourceLookupFlags lookup_flags,
80 GError **error);
81GIO_AVAILABLE_IN_2_32
82GBytes * g_resource_lookup_data (GResource *resource,
83 const char *path,
84 GResourceLookupFlags lookup_flags,
85 GError **error);
86GIO_AVAILABLE_IN_2_32
87char ** g_resource_enumerate_children (GResource *resource,
88 const char *path,
89 GResourceLookupFlags lookup_flags,
90 GError **error);
91GIO_AVAILABLE_IN_2_32
92gboolean g_resource_get_info (GResource *resource,
93 const char *path,
94 GResourceLookupFlags lookup_flags,
95 gsize *size,
96 guint32 *flags,
97 GError **error);
98
99GIO_AVAILABLE_IN_2_32
100void g_resources_register (GResource *resource);
101GIO_AVAILABLE_IN_2_32
102void g_resources_unregister (GResource *resource);
103GIO_AVAILABLE_IN_2_32
104GInputStream *g_resources_open_stream (const char *path,
105 GResourceLookupFlags lookup_flags,
106 GError **error);
107GIO_AVAILABLE_IN_2_32
108GBytes * g_resources_lookup_data (const char *path,
109 GResourceLookupFlags lookup_flags,
110 GError **error);
111GIO_AVAILABLE_IN_2_32
112char ** g_resources_enumerate_children (const char *path,
113 GResourceLookupFlags lookup_flags,
114 GError **error);
115GIO_AVAILABLE_IN_2_32
116gboolean g_resources_get_info (const char *path,
117 GResourceLookupFlags lookup_flags,
118 gsize *size,
119 guint32 *flags,
120 GError **error);
121
122
123GIO_AVAILABLE_IN_2_32
124void g_static_resource_init (GStaticResource *static_resource);
125GIO_AVAILABLE_IN_2_32
126void g_static_resource_fini (GStaticResource *static_resource);
127GIO_AVAILABLE_IN_2_32
128GResource *g_static_resource_get_resource (GStaticResource *static_resource);
129
130G_END_DECLS
131
132#endif /* __G_RESOURCE_H__ */
133