X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgresource.c;h=4e54fd21acf7061686783e6c7921afb5bb7ac0f5;hb=7a1aaaa1fa02679ecf335a19fffe3f55505921b5;hp=c6175feae8dacb0afbbb5b9b80a6da8d8017d64a;hpb=30e9cccb85bd6f398ce1f17d9a8eae98f4c2430a;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gresource.c b/gio/gresource.c
index c6175fe..4e54fd2 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -13,9 +13,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Authors: Alexander Larsson
*/
@@ -38,7 +36,7 @@ struct _GResource
GvdbTable *table;
};
-static void register_lazy_static_resources ();
+static void register_lazy_static_resources (void);
G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
@@ -47,12 +45,13 @@ G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
* @short_description: Resource framework
* @include: gio/gio.h
*
- * Applications and libraries often contain binary or textual data that is really part of the
- * application, rather than user data. For instance #GtkBuilder .ui files, splashscreen images,
- * GMenu markup xml, CSS files, icons, etc. These are often shipped as files in $datadir/appname, or
+ * Applications and libraries often contain binary or textual data that is
+ * really part of the application, rather than user data. For instance
+ * #GtkBuilder .ui files, splashscreen images, GMenu markup xml, CSS files,
+ * icons, etc. These are often shipped as files in `$datadir/appname`, or
* manually included as literal strings in the code.
*
- * The #GResource API and the glib-compile-resources program
+ * The #GResource API and the [glib-compile-resources][glib-compile-resources] program
* provide a convenient and efficient alternative to this which has some nice properties. You
* maintain the files as normal files, so its easy to edit them, but during the build the files
* are combined into a binary bundle that is linked into the executable. This means that loading
@@ -60,32 +59,33 @@ G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
* simple (no need to check for things like I/O errors or locate the files in the filesystem). It
* also makes it easier to create relocatable applications.
*
- * Resource files can also be marked as compresses. Such files will be included in the resource bundle
+ * Resource files can also be marked as compressed. Such files will be included in the resource bundle
* in a compressed form, but will be automatically uncompressed when the resource is used. This
* is very useful e.g. for larger text files that are parsed once (or rarely) and then thrown away.
*
* Resource files can also be marked to be preprocessed, by setting the value of the
- * preprocess attribute to a comma-separated list of preprocessing options.
+ * `preprocess` attribute to a comma-separated list of preprocessing options.
* The only options currently supported are:
*
- * xml-stripblanks which will use xmllint to strip
- * ignorable whitespace from the xml file. For this to work, the XMLLINT
- * environment variable must be set to the full path to the xmllint executable, or xmllint
- * must be in the PATH; otherwise the preprocessing step is skipped.
+ * `xml-stripblanks` which will use the xmllint command
+ * to strip ignorable whitespace from the xml file. For this to work,
+ * the `XMLLINT` environment variable must be set to the full path to
+ * the xmllint executable, or xmllint must be in the `PATH`; otherwise
+ * the preprocessing step is skipped.
*
- * to-pixdata which will use gdk-pixbuf-pixdata to convert
+ * `to-pixdata` which will use the gdk-pixbuf-pixdata command to convert
* images to the GdkPixdata format, which allows you to create pixbufs directly using the data inside
* the resource file, rather than an (uncompressed) copy if it. For this, the gdk-pixbuf-pixdata
- * program must be in the PATH, or the GDK_PIXBUF_PIXDATA environment variable must be
+ * program must be in the PATH, or the `GDK_PIXBUF_PIXDATA` environment variable must be
* set to the full path to the gdk-pixbuf-pixdata executable; otherwise the resource compiler will
* abort.
*
- * Resource bundles are created by the glib-compile-resources program
+ * Resource bundles are created by the [glib-compile-resources][glib-compile-resources] program
* which takes an xml file that describes the bundle, and a set of files that the xml references. These
* are combined into a binary resource bundle.
*
- * Example resource description
- *
*
*
@@ -94,19 +94,19 @@ G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
* menumarkup.xml
*
*
- * ]]>
+ * ]|
*
* This will create a resource bundle with the following files:
- *
+ * ]|
*
* Note that all resources in the process share the same namespace, so use java-style
* path prefixes (like in the above example) to avoid conflicts.
*
- * You can then use glib-compile-resources to compile the xml to a
+ * You can then use [glib-compile-resources][glib-compile-resources] to compile the xml to a
* binary bundle that you can load with g_resource_load(). However, its more common to use the --generate-source and
* --generate-header arguments to create a source file and header to link directly into your application.
*
@@ -116,10 +116,10 @@ G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
* the resource data.
*
* There are two forms of the generated source, the default version uses the compiler support for constructor
- * and destructor functions (where availible) to automatically create and register the #GResource on startup
+ * and destructor functions (where available) to automatically create and register the #GResource on startup
* or library load time. If you pass --manual-register two functions to register/unregister the resource is instead
* created. This requires an explicit initialization call in your application/library, but it works on all platforms,
- * even on the minor ones where this is not availible. (Constructor support is availible for at least Win32, MacOS and Linux.)
+ * even on the minor ones where this is not available. (Constructor support is available for at least Win32, MacOS and Linux.)
*
* Note that resource data can point directly into the data segment of e.g. a library, so if you are unloading libraries
* during runtime you need to be very careful with keeping around pointers to data from a resource, as this goes away
@@ -134,24 +134,20 @@ G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
*
* Gets the #GResource Error Quark.
*
- * Return value: a #GQuark.
+ * Returns: a #GQuark
*
* Since: 2.32
*/
-GQuark
-g_resource_error_quark (void)
-{
- return g_quark_from_static_string ("g-resource-error-quark");
-}
+G_DEFINE_QUARK (g-resource-error-quark, g_resource_error)
/**
* g_resource_ref:
- * @resource: A #GResource.
+ * @resource: A #GResource
*
* Atomically increments the reference count of @array by one. This
* function is MT-safe and may be called from any thread.
*
- * Returns: The passed in #GResource.
+ * Returns: The passed in #GResource
*
* Since: 2.32
**/
@@ -164,7 +160,7 @@ g_resource_ref (GResource *resource)
/**
* g_resource_unref:
- * @resource: A #GResource.
+ * @resource: A #GResource
*
* Atomically decrements the reference count of @resource by one. If the
* reference count drops to 0, all memory allocated by the array is
@@ -184,9 +180,27 @@ g_resource_unref (GResource *resource)
}
/**
+ * g_resource_new_from_table:
+ * @table: (transfer full): a GvdbTable
+ *
+ * Returns: (transfer full): a new #GResource for @table
+ */
+static GResource *
+g_resource_new_from_table (GvdbTable *table)
+{
+ GResource *resource;
+
+ resource = g_new (GResource, 1);
+ resource->ref_count = 1;
+ resource->table = table;
+
+ return resource;
+}
+
+/**
* g_resource_new_from_data:
- * @data: A #GBytes.
- * @error: return location for a #GError, or %NULL.
+ * @data: A #GBytes
+ * @error: return location for a #GError, or %NULL
*
* Creates a GResource from a reference to the binary resource bundle.
* This will keep a reference to @data while the resource lives, so
@@ -195,39 +209,34 @@ g_resource_unref (GResource *resource)
* If you want to use this resource in the global resource namespace you need
* to register it with g_resources_register().
*
- * Return value: (transfer full): a new #GResource, or %NULL on error.
+ * Returns: (transfer full): a new #GResource, or %NULL on error
*
* Since: 2.32
**/
GResource *
-g_resource_new_from_data (GBytes *data,
- GError **error)
+g_resource_new_from_data (GBytes *data,
+ GError **error)
{
- GResource *resource;
GvdbTable *table;
table = gvdb_table_new_from_data (g_bytes_get_data (data, NULL),
- g_bytes_get_size (data),
- TRUE,
- g_bytes_ref (data),
- (GvdbRefFunc)g_bytes_ref,
- (GDestroyNotify)g_bytes_unref,
- error);
+ g_bytes_get_size (data),
+ TRUE,
+ g_bytes_ref (data),
+ (GvdbRefFunc)g_bytes_ref,
+ (GDestroyNotify)g_bytes_unref,
+ error);
if (table == NULL)
return NULL;
- resource = g_new0 (GResource, 1);
- resource->ref_count = 1;
- resource->table = table;
-
- return resource;
+ return g_resource_new_from_table (table);
}
/**
* g_resource_load:
- * @filename: (type filename): the path of a filename to load, in the GLib filename encoding.
- * @error: return location for a #GError, or %NULL.
+ * @filename: (type filename): the path of a filename to load, in the GLib filename encoding
+ * @error: return location for a #GError, or %NULL
*
* Loads a binary resource bundle and creates a #GResource representation of it, allowing
* you to query it for data.
@@ -235,35 +244,32 @@ g_resource_new_from_data (GBytes *data,
* If you want to use this resource in the global resource namespace you need
* to register it with g_resources_register().
*
- * Return value: (transfer full): a new #GResource, or %NULL on error.
+ * Returns: (transfer full): a new #GResource, or %NULL on error
*
* Since: 2.32
**/
GResource *
-g_resource_load (const gchar *filename,
- GError **error)
+g_resource_load (const gchar *filename,
+ GError **error)
{
- GResource *resource;
GvdbTable *table;
table = gvdb_table_new (filename, FALSE, error);
if (table == NULL)
return NULL;
- resource = g_new0 (GResource, 1);
- resource->table = table;
-
- return resource;
+ return g_resource_new_from_table (table);
}
-static gboolean do_lookup (GResource *resource,
- const char *path,
- GResourceLookupFlags lookup_flags,
- gsize *size,
- guint32 *flags,
- const void **data,
- gsize *data_size,
- GError **error)
+static
+gboolean do_lookup (GResource *resource,
+ const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ gsize *size,
+ guint32 *flags,
+ const void **data,
+ gsize *data_size,
+ GError **error)
{
char *free_path = NULL;
gsize path_len;
@@ -277,13 +283,13 @@ static gboolean do_lookup (GResource *resource,
free_path[path_len-1] = 0;
}
- value = gvdb_table_get_value (resource->table, path);
+ value = gvdb_table_get_raw_value (resource->table, path);
if (value == NULL)
{
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
}
else
{
@@ -291,9 +297,12 @@ static gboolean do_lookup (GResource *resource,
GVariant *array;
g_variant_get (value, "(uu@ay)",
- &_size,
- &_flags,
- &array);
+ &_size,
+ &_flags,
+ &array);
+
+ _size = GUINT32_FROM_LE (_size);
+ _flags = GUINT32_FROM_LE (_flags);
if (size)
*size = _size;
@@ -321,10 +330,10 @@ static gboolean do_lookup (GResource *resource,
/**
* g_resource_open_stream:
- * @resource: A #GResource.
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @resource: A #GResource
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the resource and
* returns a #GInputStream that lets you read the data.
@@ -332,15 +341,15 @@ static gboolean do_lookup (GResource *resource,
* @lookup_flags controls the behaviour of the lookup.
*
* Returns: (transfer full): #GInputStream or %NULL on error.
- * Free the returned object with g_object_unref().
+ * Free the returned object with g_object_unref()
*
* Since: 2.32
**/
GInputStream *
-g_resource_open_stream (GResource *resource,
- const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+g_resource_open_stream (GResource *resource,
+ const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
const void *data;
gsize data_size;
@@ -352,13 +361,13 @@ g_resource_open_stream (GResource *resource,
stream = g_memory_input_stream_new_from_data (data, data_size, NULL);
g_object_set_data_full (G_OBJECT (stream), "g-resource",
- g_resource_ref (resource),
- (GDestroyNotify)g_resource_unref);
+ g_resource_ref (resource),
+ (GDestroyNotify)g_resource_unref);
if (flags & G_RESOURCE_FLAGS_COMPRESSED)
{
GZlibDecompressor *decompressor =
- g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
+ g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
stream2 = g_converter_input_stream_new (stream, G_CONVERTER (decompressor));
g_object_unref (decompressor);
@@ -371,10 +380,10 @@ g_resource_open_stream (GResource *resource,
/**
* g_resource_lookup_data:
- * @resource: A #GResource.
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @resource: A #GResource
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the resource and
* returns a #GBytes that lets you directly access the data in
@@ -392,15 +401,15 @@ g_resource_open_stream (GResource *resource,
* @lookup_flags controls the behaviour of the lookup.
*
* Returns: (transfer full): #GBytes or %NULL on error.
- * Free the returned object with g_bytes_unref().
+ * Free the returned object with g_bytes_unref()
*
* Since: 2.32
**/
GBytes *
-g_resource_lookup_data (GResource *resource,
- const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+g_resource_lookup_data (GResource *resource,
+ const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
const void *data;
guint32 flags;
@@ -420,7 +429,7 @@ g_resource_lookup_data (GResource *resource,
GZlibDecompressor *decompressor =
- g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
+ g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
uncompressed = g_malloc (size + 1);
@@ -430,30 +439,30 @@ g_resource_lookup_data (GResource *resource,
d_size = size;
do
- {
- res = g_converter_convert (G_CONVERTER (decompressor),
- s, s_size,
- d, d_size,
- G_CONVERTER_INPUT_AT_END,
- &bytes_read,
- &bytes_written,
- NULL);
- if (res == G_CONVERTER_ERROR)
- {
- g_free (uncompressed);
+ {
+ res = g_converter_convert (G_CONVERTER (decompressor),
+ s, s_size,
+ d, d_size,
+ G_CONVERTER_INPUT_AT_END,
+ &bytes_read,
+ &bytes_written,
+ NULL);
+ if (res == G_CONVERTER_ERROR)
+ {
+ g_free (uncompressed);
g_object_unref (decompressor);
- g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_INTERNAL,
- _("The resource at '%s' failed to decompress"),
- path);
- return NULL;
-
- }
- s += bytes_read;
- s_size -= bytes_read;
- d += bytes_written;
- d_size -= bytes_written;
- }
+ g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_INTERNAL,
+ _("The resource at '%s' failed to decompress"),
+ path);
+ return NULL;
+
+ }
+ s += bytes_read;
+ s_size -= bytes_read;
+ d += bytes_written;
+ d_size -= bytes_written;
+ }
while (res != G_CONVERTER_FINISHED);
uncompressed[size] = 0; /* Zero terminate */
@@ -468,41 +477,41 @@ g_resource_lookup_data (GResource *resource,
/**
* g_resource_get_info:
- * @resource: A #GResource.
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
+ * @resource: A #GResource
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
* @size: (out) (allow-none): a location to place the length of the contents of the file,
* or %NULL if the length is not needed
* @flags: (out) (allow-none): a location to place the flags about the file,
* or %NULL if the length is not needed
- * @error: return location for a #GError, or %NULL.
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the resource and
* if found returns information about it.
*
* @lookup_flags controls the behaviour of the lookup.
*
- * Returns: %TRUE if the file was found. %FALSE if there were errors.
+ * Returns: %TRUE if the file was found. %FALSE if there were errors
*
* Since: 2.32
**/
gboolean
-g_resource_get_info (GResource *resource,
- const char *path,
- GResourceLookupFlags lookup_flags,
- gsize *size,
- guint32 *flags,
- GError **error)
+g_resource_get_info (GResource *resource,
+ const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ gsize *size,
+ guint32 *flags,
+ GError **error)
{
return do_lookup (resource, path, lookup_flags, size, flags, NULL, NULL, error);
}
/**
* g_resource_enumerate_children:
- * @resource: A #GResource.
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @resource: A #GResource
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Returns all the names of children at the specified @path in the resource.
* The return result is a %NULL terminated list of strings which should
@@ -514,11 +523,11 @@ g_resource_get_info (GResource *resource,
*
* Since: 2.32
**/
-char **
-g_resource_enumerate_children (GResource *resource,
- const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+gchar **
+g_resource_enumerate_children (GResource *resource,
+ const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
gchar **children;
gsize path_len;
@@ -527,8 +536,8 @@ g_resource_enumerate_children (GResource *resource,
if (*path == 0)
{
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
return NULL;
}
@@ -544,8 +553,8 @@ g_resource_enumerate_children (GResource *resource,
if (children == NULL)
{
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
return NULL;
}
@@ -562,8 +571,7 @@ static GStaticResource *lazy_register_resources;
static void
g_resources_register_unlocked (GResource *resource)
{
- registered_resources = g_list_prepend (registered_resources,
- g_resource_ref (resource));
+ registered_resources = g_list_prepend (registered_resources, g_resource_ref (resource));
}
static void
@@ -571,19 +579,18 @@ g_resources_unregister_unlocked (GResource *resource)
{
if (g_list_find (registered_resources, resource) == NULL)
{
- g_warning ("Tried to remove not registred resource");
+ g_warning ("Tried to remove not registered resource");
}
else
{
- registered_resources = g_list_remove (registered_resources,
- resource);
+ registered_resources = g_list_remove (registered_resources, resource);
g_resource_unref (resource);
}
}
/**
* g_resources_register:
- * @resource: A #GResource.
+ * @resource: A #GResource
*
* Registers the resource with the process-global set of resources.
* Once a resource is registered the files in it can be accessed
@@ -601,7 +608,7 @@ g_resources_register (GResource *resource)
/**
* g_resources_unregister:
- * @resource: A #GResource.
+ * @resource: A #GResource
*
* Unregisters the resource from the process-global set of resources.
*
@@ -617,25 +624,25 @@ g_resources_unregister (GResource *resource)
/**
* g_resources_open_stream:
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the set of
- * globally registred resources and returns a #GInputStream
+ * globally registered resources and returns a #GInputStream
* that lets you read the data.
*
* @lookup_flags controls the behaviour of the lookup.
*
* Returns: (transfer full): #GInputStream or %NULL on error.
- * Free the returned object with g_object_unref().
+ * Free the returned object with g_object_unref()
*
* Since: 2.32
**/
GInputStream *
-g_resources_open_stream (const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+g_resources_open_stream (const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
GInputStream *res = NULL;
GList *l;
@@ -652,23 +659,23 @@ g_resources_open_stream (const char *path,
stream = g_resource_open_stream (r, path, lookup_flags, &my_error);
if (stream == NULL &&
- g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
- {
- g_clear_error (&my_error);
- }
+ g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
+ {
+ g_clear_error (&my_error);
+ }
else
- {
- if (stream == NULL)
- g_propagate_error (error, my_error);
- res = stream;
- break;
- }
+ {
+ if (stream == NULL)
+ g_propagate_error (error, my_error);
+ res = stream;
+ break;
+ }
}
if (l == NULL)
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
g_rw_lock_reader_unlock (&resources_lock);
@@ -677,12 +684,12 @@ g_resources_open_stream (const char *path,
/**
* g_resources_lookup_data:
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the set of
- * globally registred resources and returns a #GBytes that
+ * globally registered resources and returns a #GBytes that
* lets you directly access the data in memory.
*
* The data is always followed by a zero byte, so you
@@ -697,14 +704,14 @@ g_resources_open_stream (const char *path,
* @lookup_flags controls the behaviour of the lookup.
*
* Returns: (transfer full): #GBytes or %NULL on error.
- * Free the returned object with g_bytes_unref().
+ * Free the returned object with g_bytes_unref()
*
* Since: 2.32
**/
GBytes *
-g_resources_lookup_data (const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+g_resources_lookup_data (const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
GBytes *res = NULL;
GList *l;
@@ -721,23 +728,23 @@ g_resources_lookup_data (const char *path,
data = g_resource_lookup_data (r, path, lookup_flags, &my_error);
if (data == NULL &&
- g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
- {
- g_clear_error (&my_error);
- }
+ g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
+ {
+ g_clear_error (&my_error);
+ }
else
- {
- if (data == NULL)
- g_propagate_error (error, my_error);
- res = data;
- break;
- }
+ {
+ if (data == NULL)
+ g_propagate_error (error, my_error);
+ res = data;
+ break;
+ }
}
if (l == NULL)
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
g_rw_lock_reader_unlock (&resources_lock);
@@ -746,12 +753,12 @@ g_resources_lookup_data (const char *path,
/**
* g_resources_enumerate_children:
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
- * @error: return location for a #GError, or %NULL.
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
+ * @error: return location for a #GError, or %NULL
*
* Returns all the names of children at the specified @path in the set of
- * globally registred resources.
+ * globally registered resources.
* The return result is a %NULL terminated list of strings which should
* be released with g_strfreev().
*
@@ -761,10 +768,10 @@ g_resources_lookup_data (const char *path,
*
* Since: 2.32
**/
-char **
-g_resources_enumerate_children (const char *path,
- GResourceLookupFlags lookup_flags,
- GError **error)
+gchar **
+g_resources_enumerate_children (const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ GError **error)
{
GHashTable *hash = NULL;
GList *l;
@@ -782,14 +789,14 @@ g_resources_enumerate_children (const char *path,
children = g_resource_enumerate_children (r, path, 0, NULL);
if (children != NULL)
- {
- if (hash == NULL)
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-
- for (i = 0; children[i] != NULL; i++)
- g_hash_table_insert (hash, children[i], children[i]);
- g_free (children);
- }
+ {
+ if (hash == NULL)
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ for (i = 0; children[i] != NULL; i++)
+ g_hash_table_insert (hash, children[i], children[i]);
+ g_free (children);
+ }
}
g_rw_lock_reader_unlock (&resources_lock);
@@ -797,8 +804,8 @@ g_resources_enumerate_children (const char *path,
if (hash == NULL)
{
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
return NULL;
}
else
@@ -812,7 +819,7 @@ g_resources_enumerate_children (const char *path,
g_hash_table_iter_init (&iter, hash);
while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
- children[i++] = g_strdup (key);
+ children[i++] = g_strdup (key);
children[i++] = NULL;
g_hash_table_destroy (hash);
@@ -823,29 +830,29 @@ g_resources_enumerate_children (const char *path,
/**
* g_resources_get_info:
- * @path: A pathname inside the resource.
- * @lookup_flags: A #GResourceLookupFlags.
+ * @path: A pathname inside the resource
+ * @lookup_flags: A #GResourceLookupFlags
* @size: (out) (allow-none): a location to place the length of the contents of the file,
* or %NULL if the length is not needed
* @flags: (out) (allow-none): a location to place the flags about the file,
* or %NULL if the length is not needed
- * @error: return location for a #GError, or %NULL.
+ * @error: return location for a #GError, or %NULL
*
* Looks for a file at the specified @path in the set of
- * globally registred resources and if found returns information about it.
+ * globally registered resources and if found returns information about it.
*
* @lookup_flags controls the behaviour of the lookup.
*
- * Returns: %TRUE if the file was found. %FALSE if there were errors.
+ * Returns: %TRUE if the file was found. %FALSE if there were errors
*
* Since: 2.32
**/
gboolean
-g_resources_get_info (const char *path,
- GResourceLookupFlags lookup_flags,
- gsize *size,
- guint32 *flags,
- GError **error)
+g_resources_get_info (const gchar *path,
+ GResourceLookupFlags lookup_flags,
+ gsize *size,
+ guint32 *flags,
+ GError **error)
{
gboolean res = FALSE;
GList *l;
@@ -862,23 +869,23 @@ g_resources_get_info (const char *path,
r_res = g_resource_get_info (r, path, lookup_flags, size, flags, &my_error);
if (!r_res &&
- g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
- {
- g_clear_error (&my_error);
- }
+ g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
+ {
+ g_clear_error (&my_error);
+ }
else
- {
- if (!r_res)
- g_propagate_error (error, my_error);
- res = r_res;
- break;
- }
+ {
+ if (!r_res)
+ g_propagate_error (error, my_error);
+ res = r_res;
+ break;
+ }
}
if (l == NULL)
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
- _("The resource at '%s' does not exist"),
- path);
+ _("The resource at '%s' does not exist"),
+ path);
g_rw_lock_reader_unlock (&resources_lock);
@@ -906,7 +913,7 @@ g_resources_get_info (const char *path,
*/
static void
-register_lazy_static_resources_unlocked ()
+register_lazy_static_resources_unlocked (void)
{
GStaticResource *list;
@@ -919,10 +926,10 @@ register_lazy_static_resources_unlocked ()
GBytes *bytes = g_bytes_new_static (list->data, list->data_len);
GResource *resource = g_resource_new_from_data (bytes, NULL);
if (resource)
- {
- g_resources_register_unlocked (resource);
- g_atomic_pointer_set (&list->resource, resource);
- }
+ {
+ g_resources_register_unlocked (resource);
+ g_atomic_pointer_set (&list->resource, resource);
+ }
g_bytes_unref (bytes);
list = list->next;
@@ -930,7 +937,7 @@ register_lazy_static_resources_unlocked ()
}
static void
-register_lazy_static_resources ()
+register_lazy_static_resources (void)
{
if (g_atomic_pointer_get (&lazy_register_resources) == NULL)
return;
@@ -942,14 +949,14 @@ register_lazy_static_resources ()
/**
* g_static_resource_init:
- * @static_resource: pointer to a static #GStaticResource.
+ * @static_resource: pointer to a static #GStaticResource
*
* Initializes a GResource from static data using a
* GStaticResource.
*
* This is normally used by code generated by
- * glib-compile-resources and is
- * not typically used by other code.
+ * [glib-compile-resources][glib-compile-resources]
+ * and is not typically used by other code.
*
* Since: 2.32
**/
@@ -968,13 +975,13 @@ g_static_resource_init (GStaticResource *static_resource)
/**
* g_static_resource_fini:
- * @static_resource: pointer to a static #GStaticResource.
+ * @static_resource: pointer to a static #GStaticResource
*
- * Finalized a GResource initialized by g_static_resource_init ().
+ * Finalized a GResource initialized by g_static_resource_init().
*
* This is normally used by code generated by
- * glib-compile-resources and is
- * not typically used by other code.
+ * [glib-compile-resources][glib-compile-resources]
+ * and is not typically used by other code.
*
* Since: 2.32
**/
@@ -1000,20 +1007,20 @@ g_static_resource_fini (GStaticResource *static_resource)
/**
* g_static_resource_get_resource:
- * @static_resource: pointer to a static #GStaticResource.
+ * @static_resource: pointer to a static #GStaticResource
*
- * Gets the GResource that was registred by a call to g_static_resource_init ().
+ * Gets the GResource that was registered by a call to g_static_resource_init().
*
* This is normally used by code generated by
- * glib-compile-resources and is
- * not typically used by other code.
+ * [glib-compile-resources][glib-compile-resources]
+ * and is not typically used by other code.
*
- * Return value: (transfer none): a #GResource.
+ * Returns: (transfer none): a #GResource
*
* Since: 2.32
**/
GResource *
-g_static_resource_get_resource (GStaticResource *static_resource)
+g_static_resource_get_resource (GStaticResource *static_resource)
{
register_lazy_static_resources ();