mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
(vfs_get_current_dir): avoid string duplication.
(vfs_get_current_dir_n): new function returned newly allocated string. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e4c1ae80eb
commit
3e622b822e
@ -156,11 +156,10 @@ vfs_canon (const char *path)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *curr_dir;
|
||||
const char *curr_dir;
|
||||
|
||||
curr_dir = vfs_get_current_dir ();
|
||||
local = mc_build_filename (curr_dir, path, NULL);
|
||||
g_free (curr_dir);
|
||||
}
|
||||
result = vfs_canon (local);
|
||||
g_free (local);
|
||||
|
@ -364,11 +364,24 @@ vfs_translate_path_n (const char *path)
|
||||
/**
|
||||
* Get current directory without any OS calls.
|
||||
*
|
||||
* @return string contain current path
|
||||
* @return string contains current path
|
||||
*/
|
||||
|
||||
const char *
|
||||
vfs_get_current_dir (void)
|
||||
{
|
||||
return current_path->str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get current directory without any OS calls.
|
||||
*
|
||||
* @return newly allocated string contains current path
|
||||
*/
|
||||
|
||||
char *
|
||||
vfs_get_current_dir (void)
|
||||
vfs_get_current_dir_n (void)
|
||||
{
|
||||
return g_strdup (current_path->str);
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ void vfs_timeout_handler (void);
|
||||
int vfs_timeouts (void);
|
||||
void vfs_expire (gboolean now);
|
||||
|
||||
char *vfs_get_current_dir (void);
|
||||
const char *vfs_get_current_dir (void);
|
||||
char *vfs_get_current_dir_n (void);
|
||||
const vfs_path_t *vfs_get_raw_current_dir (void);
|
||||
void vfs_set_raw_current_dir (const vfs_path_t * vpath);
|
||||
|
||||
|
@ -914,13 +914,12 @@ done_mc (void)
|
||||
* We sync the profiles since the hotlist may have changed, while
|
||||
* we only change the setup data if we have the auto save feature set
|
||||
*/
|
||||
char *curr_dir;
|
||||
const char *curr_dir;
|
||||
|
||||
save_setup (auto_save_setup, panels_options.auto_save_setup);
|
||||
|
||||
curr_dir = vfs_get_current_dir ();
|
||||
vfs_stamp_path (curr_dir);
|
||||
g_free (curr_dir);
|
||||
|
||||
if ((current_panel != NULL) && (get_current_type () == view_listing))
|
||||
vfs_stamp_path (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
|
@ -792,18 +792,16 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
|
||||
goto ret;
|
||||
case 'd':
|
||||
{
|
||||
char *cwd;
|
||||
const char *cwd;
|
||||
char *qstr;
|
||||
|
||||
if (panel)
|
||||
cwd = g_strdup (vfs_path_as_str (panel->cwd_vpath));
|
||||
if (panel != NULL)
|
||||
cwd = vfs_path_as_str (panel->cwd_vpath);
|
||||
else
|
||||
cwd = vfs_get_current_dir ();
|
||||
|
||||
qstr = quote_func (cwd, FALSE);
|
||||
|
||||
g_free (cwd);
|
||||
|
||||
result = qstr;
|
||||
goto ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user