4 /*** typedefs(not structures) and defined constants **********************************************/
6 #define VFS_PATH_URL_DELIMITER "://"
8 /*** enums ***************************************************************************************/
13 VPF_NO_CANON
= 1 << 0,
14 VPF_USE_DEPRECATED_PARSER
= 1 << 1,
16 VPF_STRIP_HOME
= 1 << 3,
17 VPF_STRIP_PASSWORD
= 1 << 4,
18 VPF_HIDE_CHARSET
= 1 << 5
21 /*** structures declarations (and typedefs of structures)*****************************************/
24 struct vfs_url_struct
;
40 struct vfs_class
*class;
55 /*** global variables defined in .c file *********************************************************/
57 /*** declarations of public functions ************************************************************/
59 vfs_path_t
*vfs_path_new (void);
60 vfs_path_t
*vfs_path_clone (const vfs_path_t
* vpath
);
61 void vfs_path_remove_element_by_index (vfs_path_t
* vpath
, int element_index
);
62 void vfs_path_free (vfs_path_t
* path
);
63 int vfs_path_elements_count (const vfs_path_t
* path
);
65 char *vfs_path_to_str (const vfs_path_t
* path
);
66 char *vfs_path_to_str_elements_count (const vfs_path_t
* path
, int elements_count
);
67 char *vfs_path_to_str_flags (const vfs_path_t
* vpath
, int elements_count
, vfs_path_flag_t flags
);
68 vfs_path_t
*vfs_path_from_str (const char *path_str
);
69 vfs_path_t
*vfs_path_from_str_flags (const char *path_str
, vfs_path_flag_t flags
);
70 vfs_path_t
*vfs_path_build_filename (const char *first_element
, ...);
71 vfs_path_t
*vfs_path_append_new (const vfs_path_t
* vpath
, const char *first_element
, ...);
72 vfs_path_t
*vfs_path_append_vpath_new (const vfs_path_t
* first_vpath
, ...);
73 size_t vfs_path_tokens_count (const vfs_path_t
*);
74 char *vfs_path_tokens_get (const vfs_path_t
* vpath
, ssize_t start_position
, ssize_t length
);
75 vfs_path_t
*vfs_path_vtokens_get (const vfs_path_t
* vpath
, ssize_t start_position
, ssize_t length
);
77 void vfs_path_add_element (const vfs_path_t
* vpath
, const vfs_path_element_t
* path_element
);
78 const vfs_path_element_t
*vfs_path_get_by_index (const vfs_path_t
* path
, int element_index
);
79 vfs_path_element_t
*vfs_path_element_clone (const vfs_path_element_t
* element
);
80 void vfs_path_element_free (vfs_path_element_t
* element
);
82 struct vfs_class
*vfs_prefix_to_class (const char *prefix
);
85 gboolean
vfs_path_element_need_cleanup_converter (const vfs_path_element_t
* element
);
88 char *vfs_path_serialize (const vfs_path_t
* vpath
, GError
** error
);
89 vfs_path_t
*vfs_path_deserialize (const char *data
, GError
** error
);
91 char *vfs_path_build_url_params_str (const vfs_path_element_t
* element
, gboolean keep_password
);
92 char *vfs_path_element_build_pretty_path_str (const vfs_path_element_t
* element
);
94 size_t vfs_path_len (const vfs_path_t
* vpath
);
95 int vfs_path_cmp (const vfs_path_t
* vpath1
, const vfs_path_t
* vpath2
);
96 int vfs_path_ncmp (const vfs_path_t
* vpath1
, const vfs_path_t
* vpath2
, size_t len
);
97 vfs_path_t
*vfs_path_to_absolute (const vfs_path_t
* vpath
);
99 /*** inline functions ****************************************************************************/
101 static inline gboolean
102 vfs_path_element_valid (const vfs_path_element_t
* element
)
104 return (element
!= NULL
&& element
->class != NULL
);
107 /* --------------------------------------------------------------------------------------------- */
109 static inline const char *
110 vfs_path_get_last_path_str (const vfs_path_t
* vpath
)
112 const vfs_path_element_t
*element
;
115 element
= vfs_path_get_by_index (vpath
, -1);
116 return (element
!= NULL
) ? element
->path
: NULL
;
119 /* --------------------------------------------------------------------------------------------- */
121 static inline const struct vfs_class
*
122 vfs_path_get_last_path_vfs (const vfs_path_t
* vpath
)
124 const vfs_path_element_t
*element
;
127 element
= vfs_path_get_by_index (vpath
, -1);
128 return (element
!= NULL
) ? element
->class : NULL
;