| Libfm Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#define FM_PATH (path) FmFileInfoList; struct FmPath; enum FmPathFlags; FmPathList; int fm_path_depth (FmPath *path); char * fm_path_display_basename (FmPath *path); char * fm_path_display_name (FmPath *path,gboolean human_readable); gboolean fm_path_equal (FmPath *p1,FmPath *p2); gboolean fm_path_equal_str (FmPath *path,const gchar *str,int n); FmPath * fm_path_get_apps_menu (void); const char * fm_path_get_basename (FmPath *path); FmPath * fm_path_get_desktop (void); FmPathFlags fm_path_get_flags (FmPath *path); FmPath * fm_path_get_home (void); FmPath * fm_path_get_parent (FmPath *path); FmPath * fm_path_get_root (void); FmPath * fm_path_get_trash (void); gboolean fm_path_has_prefix (FmPath *path,FmPath *prefix); guint fm_path_hash (FmPath *path); #define fm_path_is_local (path) #define fm_path_is_native (path) #define fm_path_is_trash (path) #define fm_path_is_trash_root (path) #define fm_path_is_virtual (path) #define fm_path_is_xdg_menu (path) FmPathList * fm_path_list_new (void); FmPathList * fm_path_list_new_from_file_info_glist (GList *fis); FmPathList * fm_path_list_new_from_file_info_gslist (GSList *fis); FmPathList * fm_path_list_new_from_file_info_list (FmFileInfoList *fis); FmPathList * fm_path_list_new_from_uri_list (const char *uri_list); FmPathList * fm_path_list_new_from_uris (char * const*uris); char * fm_path_list_to_uri_list (FmPathList *pl); void fm_path_list_write_uri_list (FmPathList *pl,GString *buf); FmPath * fm_path_new_child (FmPath *parent,const char *basename); FmPath * fm_path_new_child_len (FmPath *parent,const char *basename,int name_len); FmPath * fm_path_new_for_commandline_arg (const char *arg); FmPath * fm_path_new_for_display_name (const char *path_name); FmPath * fm_path_new_for_gfile (GFile *gf); FmPath * fm_path_new_for_path (const char *path_name); FmPath * fm_path_new_for_str (const char *path_str); FmPath * fm_path_new_for_uri (const char *uri); FmPath * fm_path_new_relative (FmPath *parent,const char *rel); FmPath * fm_path_ref (FmPath *path); GFile * fm_path_to_gfile (FmPath *path); char * fm_path_to_str (FmPath *path); char * fm_path_to_uri (FmPath *path); void fm_path_unref (FmPath *path);
struct FmPath {
gint n_ref;
FmPath* parent;
guchar flags; /* FmPathFlags flags : 8; */
char name[1];
};
typedef enum {
FM_PATH_NONE = 0,
FM_PATH_IS_NATIVE = 1<<0, /* This is a native path to UNIX, like /home */
FM_PATH_IS_LOCAL = 1<<1, /* This path refers to a file on local filesystem */
FM_PATH_IS_VIRTUAL = 1<<2, /* This path is virtual and it doesn't exist on real filesystem */
FM_PATH_IS_TRASH = 1<<3, /* This path is under trash:/// */
FM_PATH_IS_XDG_MENU = 1<<4, /* This path is under menu:/// */
/* reserved for future use */
FM_PATH_IS_RESERVED1 = 1<<5,
FM_PATH_IS_RESERVED2 = 1<<6,
FM_PATH_IS_RESERVED3 = 1<<7,
} FmPathFlags;
gboolean fm_path_has_prefix (FmPath *path,FmPath *prefix);
Check if prefix is a prefix of path.
For example: /usr/share is the prefix of /usr/share/docs/libfm
but /etc is not.
|
a sub path |
|
a prefix |
Returns : |
TRUE if prefix is the prefix of path. |
#define fm_path_is_native(path) ((fm_path_get_flags(path)&FM_PATH_IS_NATIVE)!=0)
#define fm_path_is_virtual(path) ((fm_path_get_flags(path)&FM_PATH_IS_VIRTUAL)!=0)
#define fm_path_is_xdg_menu(path) ((fm_path_get_flags(path)&FM_PATH_IS_XDG_MENU)!=0)
FmPathList * fm_path_list_new_from_file_info_glist
(GList *fis);
FmPathList * fm_path_list_new_from_file_info_gslist
(GSList *fis);
FmPathList * fm_path_list_new_from_file_info_list
(FmFileInfoList *fis);
FmPathList * fm_path_list_new_from_uri_list (const char *uri_list);
FmPath * fm_path_new_child (FmPath *parent,const char *basename);
Creates new FmPath for child of parent directory which have name
basename. basename is in glib filename encoding (can be non-UTF-8).
|
a parent path |
|
basename of a direct child of parent directory |
Returns : |
a new FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. [transfer full]
|
FmPath * fm_path_new_child_len (FmPath *parent,const char *basename,int name_len);
Creates new FmPath for child of parent directory which have name
basename. The string length of basename is name_len. basename is
in glib filename encoding (can be non-UTF-8).
|
a parent path |
|
basename of a direct child of parent directory |
|
length of basename
|
Returns : |
a new FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. [transfer full]
|
FmPath * fm_path_new_for_commandline_arg (const char *arg);
|
a file path passed in command line argv to the program. The arg
can be a POSIX path in glib filename encoding (can be non-UTTF-8) and
can be a URI with non-ASCII characters escaped, like
http://wiki.lxde.org/zh/E9%A696%E9A0%81. |
Returns : |
a newly created FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. |
FmPath * fm_path_new_for_display_name (const char *path_name);
You can call fm_path_display_name() to convert a FmPath to a
UTF-8 encoded name ready for being displayed in the GUI.
|
a UTF-8 encoded display name for the path It can either be a POSIX path in UTF-8 encoding, or an unescaped URI (can contain non-ASCII characters and spaces) |
Returns : |
a newly created FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. |
FmPath * fm_path_new_for_gfile (GFile *gf);
This function converts a GFile object to FmPath.
|
a GFile object |
Returns : |
a newly created FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. |
FmPath * fm_path_new_for_path (const char *path_name);
|
a POSIX path. |
Returns : |
a newly created FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. |
FmPath * fm_path_new_for_str (const char *path_str);
You can call fm_path_to_str() to convert a FmPath back to its string
presentation.
|
a string representing the file path in its native encoding (can be non-UTF-8). It can either be a native path or an unescaped URI (can contain non-ASCII characters and spaces). The function will try to figure out what to do. |
Returns : |
a newly created FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. |
FmPath * fm_path_new_for_uri (const char *uri);
Creates new FmPath by given uri.
Encoded URI such as http://wiki.lxde.org/zh/E9%A696%E9A0%81
will be unescaped.
You can call fm_path_to_uri() to convert a FmPath to a escaped URI
string.
|
a URI with special characters escaped. |
Returns : |
a new FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. [transfer full]
|
FmPath * fm_path_new_relative (FmPath *parent,const char *rel);
Creates new FmPath which is relative to parent directory by the
relative path string rel. rel is in glib filename encoding. (can be
non-UTF-8). However this should not be a escaped ASCII string used in
URI. If you're building a relative path for a URI, and the relative
path is escaped, you have to unescape it first.
For example, if parent is "http://wiki.lxde.org/" and rel is
"zh/E9%A696%E9A0%81", you have to unescape the relative path
prior to passing it to fm_path_new_relative().
If parent is NULL, this works the same as fm_path_new_for_str(rel)
|
a parent path |
|
a path relative to parent
|
Returns : |
a new FmPath for the path. You have to call
fm_path_unref() when it's no longer needed. [transfer full]
|