(vfs_path_new): add argument to create relative path object.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-04-02 15:46:26 +03:00
parent 43fc63be8e
commit 52572d5b80
4 changed files with 11 additions and 16 deletions

View File

@ -380,7 +380,7 @@ vfs_path_from_str_deprecated_parser (char *path)
struct vfs_class *class;
const char *local, *op;
vpath = vfs_path_new ();
vpath = vfs_path_new (FALSE);
while ((class = _vfs_split_with_semi_skip_count (path, &local, &op, 0)) != NULL)
{
@ -443,8 +443,7 @@ vfs_path_from_str_uri_parser (char *path)
vfs_path_element_t *element;
char *url_delimiter;
vpath = vfs_path_new ();
vpath->relative = path != NULL && !IS_PATH_SEP (*path);
vpath = vfs_path_new (path != NULL && !IS_PATH_SEP (*path));
while ((url_delimiter = g_strrstr (path, VFS_PATH_URL_DELIMITER)) != NULL)
{
@ -776,12 +775,13 @@ vfs_path_from_str (const char *path_str)
*/
vfs_path_t *
vfs_path_new (void)
vfs_path_new (gboolean relative)
{
vfs_path_t *vpath;
vpath = g_new0 (vfs_path_t, 1);
vpath->path = g_array_new (FALSE, TRUE, sizeof (vfs_path_element_t *));
vpath->relative = relative;
return vpath;
}
@ -936,8 +936,7 @@ vfs_path_clone (const vfs_path_t * vpath)
if (vpath == NULL)
return NULL;
new_vpath = vfs_path_new ();
new_vpath->relative = vpath->relative;
new_vpath = vfs_path_new (vpath->relative);
for (vpath_element_index = 0; vpath_element_index < vfs_path_elements_count (vpath);
vpath_element_index++)
@ -1181,7 +1180,7 @@ vfs_path_deserialize (const char *data, GError ** mcerror)
if (cpath == NULL)
return NULL;
vpath = vfs_path_new ();
vpath = vfs_path_new (FALSE);
for (element_index = 0;; element_index++)
{
@ -1321,7 +1320,7 @@ vfs_path_append_vpath_new (const vfs_path_t * first_vpath, ...)
if (first_vpath == NULL)
return NULL;
ret_vpath = vfs_path_new ();
ret_vpath = vfs_path_new (FALSE);
va_start (args, first_vpath);
do

View File

@ -57,7 +57,7 @@ typedef struct
/*** declarations of public functions ************************************************************/
vfs_path_t *vfs_path_new (void);
vfs_path_t *vfs_path_new (gboolean relative);
vfs_path_t *vfs_path_clone (const vfs_path_t * vpath);
void vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index);
char *vfs_path_free (vfs_path_t * path, gboolean free_str);

View File

@ -1247,10 +1247,7 @@ panel_correct_path_to_show (const WPanel * panel)
}
}
else
{
last_vpath = vfs_path_new ();
last_vpath->relative = TRUE;
}
last_vpath = vfs_path_new (TRUE);
vfs_path_add_element (last_vpath, path_element);
return_path =
@ -4947,7 +4944,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
GString *tmp_conv;
int indx;
ret_vpath = vfs_path_new ();
ret_vpath = vfs_path_new (FALSE);
tmp_conv = g_string_new ("");

View File

@ -175,8 +175,7 @@ START_TEST (test_vpath_to_str_filter)
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, -1));
vfs_path_free (vpath, TRUE);
last_vpath = vfs_path_new ();
last_vpath->relative = TRUE;
last_vpath = vfs_path_new (TRUE);
vfs_path_add_element (last_vpath, path_element);