Rewritten vfs_canon_and_translate() function for using glib functions.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-12-29 16:11:59 +02:00
parent ec1a52fb0a
commit c73e282823

View File

@ -58,24 +58,22 @@ static inline char *vfs_translate_path_n (const char *path)
static inline char* vfs_canon_and_translate(const char* path)
{
char buf[MC_MAXPATHLEN];
char *ret_str;
if (path == NULL)
return strdup("");
return g_strdup("");
if (path[0] == PATH_SEP)
{
char cwd[MC_MAXPATHLEN];
if (getcwd (cwd, sizeof (cwd)))
snprintf (buf, sizeof (buf), "%s" PATH_SEP_STR "%s", cwd, path);
else
return strdup ("[MC_MAXPATHLEN TOO SMALL]");
char *curr_dir = g_get_current_dir();
ret_str = g_strdup_printf("%s" PATH_SEP_STR "%s", curr_dir, path);
g_free(curr_dir);
}
else
snprintf (buf, sizeof (buf), "%s", path);
ret_str = g_strdup(path);
canonicalize_pathname (buf);
return strdup (buf);
canonicalize_pathname (ret_str);
return ret_str;
}
#endif /* ENABLE_VFS */