![]() |
![]() |
![]() |
APT2 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <apt.h> gboolean (*AptUtilsForeachInDirFunc) (gpointer user_data
,const gchar *file
,GError **error
); gboolean apt_utils_foreach_in_dir (const gchar *dirname
,const gchar *suffix
,AptUtilsForeachInDirFunc callback
,gpointer user_data
,GError **error
); gint apt_utils_lock_file (const gchar *file
,GError **error
); gboolean apt_utils_match (const gchar *pattern
,const gchar *string
); gboolean apt_utils_str_case_equal (gconstpointer s1
,gconstpointer s2
); guint apt_utils_str_case_hash (gconstpointer v
); gchar * apt_utils_uri_to_filename (const gchar *uri
);
This section documents various utility functions that are needed for APT2 and may also be useful to applications using APT2.
gboolean (*AptUtilsForeachInDirFunc) (gpointer user_data
,const gchar *file
,GError **error
);
The type of the callback function passed to apt_utils_foreach_in_dir()
.
|
The user data passed to apt_utils_foreach_in_dir() . |
|
The path to the file. |
|
The location to store an error. |
Returns : |
TRUE if no error occured, FALSE otherwise. Returning
FALSE will cancel apt_utils_foreach_in_dir() . |
gboolean apt_utils_foreach_in_dir (const gchar *dirname
,const gchar *suffix
,AptUtilsForeachInDirFunc callback
,gpointer user_data
,GError **error
);
Calls the function callback
for each file in the directory (given
the complete path to the file) that ends with suffix
or consists
only of alphanumeric, hyphen-minus (-), underscore (_) and period
characters.
If callback
encounters an error, it should return FALSE
and set
its error pointer. In such a case, this function exits immediately
with the value FALSE
and propagates the error of callback
to the
caller.
|
The path to the directory that shall be read. |
|
The suffix the files should have (including .) |
|
The AptUtilsForeachInDirFunc to be called for each file in the directory. |
|
The pointer that will be passed to callback as its first
argument. |
|
The location to store an error. |
Returns : |
TRUE if everything is OK, FALSE if this function or
callback encountered an error. |
gint apt_utils_lock_file (const gchar *file
,GError **error
);
Acquires an advisory POSIX write lock for the file
file
. If any other process already holds a lock
on file
or if the file can not be locked due to
other reasons, the return value is -1 and error
is set to an error describing the reason why the
lock could not be acquired.
Since this uses POSIX locking, calling close()
on
any file descriptor for the file file
will release
all locks on this file.
|
The path to the file that shall be locked. |
|
Location to store a GFileError. |
Returns : |
The file descriptor of the lock file, or -1 on failure. |
gboolean apt_utils_match (const gchar *pattern
,const gchar *string
);
Checks whether pattern
matches string
.
gboolean apt_utils_str_case_equal (gconstpointer s1
,gconstpointer s2
);
Checks whether the two strings s1
and s2
are equal,
ignoring differing cases of ASCII characters.
guint apt_utils_str_case_hash (gconstpointer v
);
Converts a string to a hash value, ignoring the case of ASCII characters.
|
a string key |
Returns : |
a hash value corresponding to the key |
gchar * apt_utils_uri_to_filename (const gchar *uri
);
Converts uri
, excluding scheme and userinfo, into a string that can
be used as a local filename. For this, forward slashes are replaced
by underscores; the other remaining reserved characters, excluding
the colon but including the tilde character, are replaced using
their percent-encoded form.
|
A valid Uniform Resource Identifier (URI) as specified in RFC 3986 |
Returns : |
A newly allocated, escaped version of uri . The returned
string should be freed when no longer needed. |