(vfs_strip_suffix_from_filename): refactoring.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-07-07 15:34:36 +03:00
parent b808dc564f
commit e2c62afcc7
1 changed files with 10 additions and 10 deletions

View File

@ -321,24 +321,24 @@ vfs_register_class (struct vfs_class * vfs)
char *
vfs_strip_suffix_from_filename (const char *filename)
{
char *semi, *p, *vfs_prefix;
char *semi, *p;
if (filename == NULL)
vfs_die ("vfs_strip_suffix_from_path got NULL: impossible");
p = g_strdup (filename);
semi = g_strrstr (p, VFS_PATH_URL_DELIMITER);
if (semi == NULL)
return p;
*semi = '\0';
vfs_prefix = strrchr (p, PATH_SEP);
if (vfs_prefix == NULL)
if (semi != NULL)
{
*semi = *VFS_PATH_URL_DELIMITER;
return p;
char *vfs_prefix;
*semi = '\0';
vfs_prefix = strrchr (p, PATH_SEP);
if (vfs_prefix == NULL)
*semi = *VFS_PATH_URL_DELIMITER;
else
*vfs_prefix = '\0';
}
*vfs_prefix = '\0';
return p;
}