![]() |
![]() |
![]() |
Libfm Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
Common Libfm utilities.Common Libfm utilities. — Common utility functions used by libfm and libfm-gtk. |
const char * (*FmAppCommandParseCallback) (char opt
,gpointer user_data
); struct FmAppCommandParseOption; int fm_app_command_parse (const char *cmd
,const FmAppCommandParseOption *opts
,char **ret
,gpointer user_data
); char * fm_canonicalize_filename (const char *filename
,const char *cwd
); char * fm_file_size_to_str (char *buf
,size_t buf_size
,goffset size
,gboolean si_prefix
); char * fm_file_size_to_str2 (char *buf
,size_t buf_size
,goffset size
,char size_units
); const char * fm_get_home_dir (void
); gboolean fm_key_file_get_bool (GKeyFile *kf
,const char *grp
,const char *key
,gboolean *val
); gboolean fm_key_file_get_int (GKeyFile *kf
,const char *grp
,const char *key
,int *val
); gboolean fm_run_in_default_main_context (GSourceFunc func
,gpointer data
); void fm_strcatv (char ***strvp
,char * const *astrv
); char * fm_strdup_replace (char *str
,char *old_str
,char *new_str
); char * fm_uri_subpath_to_native_subpath (const char *subpath
,GError **error
);
const char * (*FmAppCommandParseCallback) (char opt
,gpointer user_data
);
The handler which converts key char into string representation.
See also: fm_app_command_parse()
.
|
key character |
|
data passed from caller of fm_app_command_parse()
|
Returns : |
string representation. |
Since 1.0.0
struct FmAppCommandParseOption { char opt; FmAppCommandParseCallback callback; };
Element of correspondence for substitutions by fm_app_command_parse()
.
key character | |
FmAppCommandParseCallback |
subroutine to get string for substitution |
int fm_app_command_parse (const char *cmd
,const FmAppCommandParseOption *opts
,char **ret
,gpointer user_data
);
This function parses line that contains some %<char> commands and does
substitutions on them using callbacks provided by caller. Only options
in opts
and %% will be expanded, all other %<char> sequences will
be skipped.
|
line to parse |
|
plain list of possible options |
|
pointer for resulting string, string should be freed by caller. [out][transfer full] |
|
caller data to pass to callback |
Returns : |
number of valid options found in cmd . |
Since 1.0.0
char * fm_canonicalize_filename (const char *filename
,const char *cwd
);
Makes a canonical name with full path from filename
. Returned string
should be freed by caller after usage.
|
a filename |
|
current work directory path |
Returns : |
a canonical name. [transfer full] |
Since 0.1.0
char * fm_file_size_to_str (char *buf
,size_t buf_size
,goffset size
,gboolean si_prefix
);
Converts size
into text representation of form "21.4 kiB" for example.
|
pointer to array to make a string |
|
size of buf
|
|
number to convert |
|
TRUE to convert in SI units, FALSE to convert in IEC units |
Returns : |
buf . |
Since 0.1.0
char * fm_file_size_to_str2 (char *buf
,size_t buf_size
,goffset size
,char size_units
);
Converts size
into text representation of form "21.4 kiB" for example.
The size_units
defines which unit will be selected to convert (similar
to ones that 'du' utility uses):
b : bytes
k : KiB (1024 bytes)
m : MiB (1048576 bytes)
g : GiB (1073741824 bytes)
K : kB (1000 bytes)
M : MB (1000000 bytes)
G : GB (1000000000 bytes)
h : adaptive in IEC units
H : adaptive in SI units
|
pointer to array to make a string |
|
size of buf
|
|
number to convert |
|
type of units to convert |
Returns : |
buf . |
Since 0.1.0
const char * fm_get_home_dir (void
);
Retrieves valid path to home dir of user.
Returns : |
path string. |
Since 1.0.2
gboolean fm_key_file_get_bool (GKeyFile *kf
,const char *grp
,const char *key
,gboolean *val
);
Lookups key
in kf
and stores found value in val
if the key
was found.
|
a key file |
|
group to lookup key |
|
a key to lookup |
|
location to store value |
Returns : |
TRUE if key was found. |
Since 0.1.0
gboolean fm_key_file_get_int (GKeyFile *kf
,const char *grp
,const char *key
,int *val
);
Lookups key
in kf
and stores found value in val
if the key
was found.
|
a key file |
|
group to lookup key |
|
a key to lookup |
|
location to store value |
Returns : |
TRUE if key was found. |
Since 0.1.0
gboolean fm_run_in_default_main_context (GSourceFunc func
,gpointer data
);
Runs func
once in global main loop with supplied data
.
|
function to run |
|
data supplied for func
|
Returns : |
output of func . |
Since 1.0.2
void fm_strcatv (char ***strvp
,char * const *astrv
);
Appends string list astrv
to strvp
replacing it.
|
pointer to strings list |
|
list of strings to append. [allow-none] |
Since 1.2.0
char * fm_strdup_replace (char *str
,char *old_str
,char *new_str
);
Replaces every occurence of old_str
in str
with new_str
and returns
resulted string. Returned string should be freed with g_free()
after
usage.
Before 1.0.0 this API had name fm_str_replace.
|
a string |
|
substring to replace |
|
string to replace old_str
|
Returns : |
resulted string. [transfer full] |
Since 0.1.16
char * fm_uri_subpath_to_native_subpath (const char *subpath
,GError **error
);
Converts escaped URI subpath into file path in native encoding.
|
URI substring to convert |
|
location to set error. [out][allow-none] |
Returns : |
transcoded path or NULL in case of error. [transfer full]
|
Since 1.2.0