Changed interface of functions mc_getlocalcopy() and mc_ungetlocalcopy()

...to handle vfs_path_t object as parameter.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-07-24 15:27:48 +03:00
parent 893ed22259
commit 490af62655
9 changed files with 169 additions and 170 deletions

View File

@ -742,11 +742,11 @@ vfs_s_ferrno (struct vfs_class *me)
* for remote filesystems. Archives use standard VFS facilities.
*/
static char *
static vfs_path_t *
vfs_s_getlocalcopy (const vfs_path_t * vpath)
{
vfs_file_handler_t *fh;
char *local = NULL;
vfs_path_t *local = NULL;
if (vpath == NULL)
return NULL;
@ -759,7 +759,7 @@ vfs_s_getlocalcopy (const vfs_path_t * vpath)
me = vfs_path_get_by_index (vpath, -1)->class;
if ((MEDATA->flags & VFS_S_USETMP) != 0 && (fh->ino != NULL))
local = g_strdup (fh->ino->localname);
local = vfs_path_from_str_flags (fh->ino->localname, VPF_NO_CANON);
vfs_s_close (fh);
}
@ -774,7 +774,7 @@ vfs_s_getlocalcopy (const vfs_path_t * vpath)
*/
static int
vfs_s_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
vfs_s_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboolean has_changed)
{
(void) vpath;
(void) local;

View File

@ -75,23 +75,20 @@ struct dirent *mc_readdir_result = NULL;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static char *
mc_def_getlocalcopy (const char *filename)
static vfs_path_t *
mc_def_getlocalcopy (const vfs_path_t * filename_vpath)
{
char *tmp = NULL;
vfs_path_t *tmp_vpath = NULL;
int fdin = -1, fdout = -1;
ssize_t i;
char buffer[BUF_1K * 8];
struct stat mystat;
vfs_path_t *vpath;
vpath = vfs_path_from_str (filename);
fdin = mc_open (vpath, O_RDONLY | O_LINEAR);
fdin = mc_open (filename_vpath, O_RDONLY | O_LINEAR);
if (fdin == -1)
goto fail;
fdout = vfs_mkstemps (&tmp_vpath, "vfs", filename);
fdout = vfs_mkstemps (&tmp_vpath, "vfs", vfs_path_get_last_path_str (filename_vpath));
if (fdout == -1)
goto fail;
@ -114,44 +111,43 @@ mc_def_getlocalcopy (const char *filename)
goto fail;
}
if (mc_stat (vpath, &mystat) != -1)
if (mc_stat (filename_vpath, &mystat) != -1)
mc_chmod (tmp_vpath, mystat.st_mode);
tmp = vfs_path_to_str (tmp_vpath);
return tmp_vpath;
fail:
vfs_path_free (vpath);
vfs_path_free (tmp_vpath);
if (fdout != -1)
close (fdout);
if (fdin != -1)
mc_close (fdin);
return tmp;
return NULL;
}
/* --------------------------------------------------------------------------------------------- */
static int
mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename,
const char *local, int has_changed)
mc_def_ungetlocalcopy (const vfs_path_t * filename_vpath,
const vfs_path_t * local_vpath, gboolean has_changed)
{
vfs_path_t *vpath;
int fdin = -1, fdout = -1;
char *local;
vpath = vfs_path_from_str (filename);
local = vfs_path_get_last_path_str (local_vpath);
if (has_changed)
{
char buffer[BUF_1K * 8];
ssize_t i;
if (!vfs->write)
if (vfs_path_get_last_path_vfs (filename_vpath)->write == NULL)
goto failed;
fdin = open (local, O_RDONLY);
if (fdin == -1)
goto failed;
fdout = mc_open (vpath, O_WRONLY | O_TRUNC);
fdout = mc_open (filename_vpath, O_WRONLY | O_TRUNC);
if (fdout == -1)
goto failed;
while ((i = read (fdin, buffer, sizeof (buffer))) > 0)
@ -173,17 +169,15 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename,
}
}
unlink (local);
vfs_path_free (vpath);
return 0;
failed:
message (D_ERROR, _("Changes to file lost"), "%s", filename);
message (D_ERROR, _("Changes to file lost"), "%s", vfs_path_get_last_path_str (filename_vpath));
if (fdout != -1)
mc_close (fdout);
if (fdin != -1)
close (fdin);
unlink (local);
vfs_path_free (vpath);
return -1;
}
@ -622,53 +616,47 @@ mc_get_current_wd (char *buffer, size_t size)
/* --------------------------------------------------------------------------------------------- */
char *
mc_getlocalcopy (const char *pathname)
vfs_path_t *
mc_getlocalcopy (const vfs_path_t * pathname_vpath)
{
char *result = NULL;
vfs_path_t *vpath;
vfs_path_t *result = NULL;
vfs_path_element_t *path_element;
vpath = vfs_path_from_str (pathname);
if (vpath == NULL)
if (pathname_vpath == NULL)
return NULL;
path_element = vfs_path_get_by_index (vpath, -1);
path_element = vfs_path_get_by_index (pathname_vpath, -1);
if (vfs_path_element_valid (path_element))
{
result = path_element->class->getlocalcopy != NULL ?
path_element->class->getlocalcopy (vpath) : mc_def_getlocalcopy (pathname);
path_element->class-> getlocalcopy (pathname_vpath) :
mc_def_getlocalcopy (pathname_vpath);
if (result == NULL)
errno = vfs_ferrno (path_element->class);
}
vfs_path_free (vpath);
return result;
}
/* --------------------------------------------------------------------------------------------- */
int
mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
mc_ungetlocalcopy (const vfs_path_t * pathname_vpath, const vfs_path_t * local_vpath,
gboolean has_changed)
{
int return_value = -1;
vfs_path_t *vpath;
vfs_path_element_t *path_element;
vpath = vfs_path_from_str (pathname);
if (vpath == NULL)
if (pathname_vpath == NULL)
return -1;
path_element = vfs_path_get_by_index (vpath, -1);
path_element = vfs_path_get_by_index (pathname_vpath, -1);
if (vfs_path_element_valid (path_element))
{
return_value = path_element->class->ungetlocalcopy != NULL ?
path_element->class->ungetlocalcopy (vpath, local,
has_changed) :
mc_def_ungetlocalcopy (path_element->class, path_element->path, local, has_changed);
}
vfs_path_free (vpath);
path_element->class->ungetlocalcopy (pathname_vpath, local_vpath, has_changed) :
mc_def_ungetlocalcopy (pathname_vpath, local_vpath, has_changed);
return return_value;
}

View File

@ -184,8 +184,9 @@ typedef struct vfs_class
int (*nothingisopen) (vfsid id);
void (*free) (vfsid id);
char *(*getlocalcopy) (const vfs_path_t * vpath);
int (*ungetlocalcopy) (const vfs_path_t * vpath, const char *local, int has_changed);
vfs_path_t *(*getlocalcopy) (const vfs_path_t * vpath);
int (*ungetlocalcopy) (const vfs_path_t * vpath, const vfs_path_t * local_vpath,
gboolean has_changed);
int (*mkdir) (const vfs_path_t * vpath, mode_t mode);
int (*rmdir) (const vfs_path_t * vpath);
@ -301,8 +302,9 @@ int mc_ctl (int fd, int ctlop, void *arg);
int mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg);
int mc_open (const vfs_path_t * vpath, int flags, ...);
char *mc_get_current_wd (char *buffer, size_t bufsize);
char *mc_getlocalcopy (const char *pathname);
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
vfs_path_t *mc_getlocalcopy (const vfs_path_t * pathname_vpath);
int mc_ungetlocalcopy (const vfs_path_t * pathname_vpath, const vfs_path_t * local_vpath,
gboolean has_changed);
int mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix);
/* Creating temporary files safely */

View File

@ -3331,22 +3331,18 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
#define GET_FILE_AND_STAMP(n) \
do \
{ \
vfs_path_t *vpath = vfs_path_from_str(file##n); \
use_copy##n = 0; \
real_file##n = file##n; \
if (!vfs_file_is_local (vpath)) \
if (!vfs_file_is_local (file##n)) \
{ \
real_file##n = mc_getlocalcopy (file##n); \
if (real_file##n != NULL) \
{ \
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
use_copy##n = 1; \
if (mc_stat (tmp_vpath, &st##n) != 0) \
if (mc_stat (real_file##n, &st##n) != 0) \
use_copy##n = -1; \
vfs_path_free (tmp_vpath); \
} \
} \
vfs_path_free(vpath); \
} \
while (0)
@ -3359,14 +3355,12 @@ do \
if (use_copy##n > 0) \
{ \
time_t mtime; \
vfs_path_t *tmp_vpath = vfs_path_from_str (real_file##n); \
mtime = st##n.st_mtime; \
if (mc_stat (tmp_vpath, &st##n) == 0) \
if (mc_stat (real_file##n, &st##n) == 0) \
changed = (mtime != st##n.st_mtime); \
vfs_path_free (tmp_vpath); \
} \
mc_ungetlocalcopy (file##n, real_file##n, changed); \
g_free (real_file##n); \
vfs_path_free (real_file##n); \
} \
} \
while (0)
@ -3375,8 +3369,8 @@ void
dview_diff_cmd (void)
{
int rv = 0;
char *file0 = NULL;
char *file1 = NULL;
vfs_path_t *file0 = NULL;
vfs_path_t *file1 = NULL;
int is_dir0 = 0;
int is_dir1 = 0;
@ -3389,8 +3383,8 @@ dview_diff_cmd (void)
panel0 = other_panel;
panel1 = current_panel;
}
file0 = concat_dir_and_file (panel0->cwd, selection (panel0)->fname);
file1 = concat_dir_and_file (panel1->cwd, selection (panel1)->fname);
file0 = vfs_path_build_filename (panel0->cwd, selection (panel0)->fname, NULL);
file1 = vfs_path_build_filename (panel1->cwd, selection (panel1)->fname, NULL);
is_dir0 = S_ISDIR (selection (panel0)->st.st_mode);
is_dir1 = S_ISDIR (selection (panel1)->st.st_mode);
}
@ -3404,21 +3398,33 @@ dview_diff_cmd (void)
int use_copy1;
struct stat st0;
struct stat st1;
char *real_file0;
char *real_file1;
vfs_path_t *real_file0;
vfs_path_t *real_file1;
GET_FILE_AND_STAMP (0);
GET_FILE_AND_STAMP (1);
if (real_file0 != NULL && real_file1 != NULL)
{
rv = diff_view (real_file0, real_file1, file0, file1);
char *real_file0_str, *real_file1_str;
char *file0_str, *file1_str;
real_file0_str = vfs_path_to_str (real_file0);
real_file1_str = vfs_path_to_str (real_file1);
file0_str = vfs_path_to_str (file0);
file1_str = vfs_path_to_str (file1);
rv = diff_view (real_file0_str, real_file1_str, file0_str, file1_str);
g_free (real_file0_str);
g_free (real_file1_str);
g_free (file0_str);
g_free (file1_str);
}
UNGET_FILE (1);
UNGET_FILE (0);
}
}
g_free (file1);
g_free (file0);
vfs_path_free (file1);
vfs_path_free (file0);
if (rv == 0)
message (D_ERROR, MSG_ERROR, _("Two files are needed to compare"));

View File

@ -438,8 +438,6 @@ execute_suspend (const gchar * event_group_name, const gchar * event_name,
void
execute_with_vfs_arg (const char *command, const char *filename)
{
char *localcopy;
char *fn;
struct stat st;
time_t mtime;
vfs_path_t *vpath = vfs_path_from_str (filename);
@ -448,40 +446,38 @@ execute_with_vfs_arg (const char *command, const char *filename)
/* Simplest case, this file is local */
if (!filename || vfs_file_is_local (vpath))
{
fn = vfs_path_to_str (vpath);
do_execute (command, fn, EXECUTE_INTERNAL);
g_free (fn);
do_execute (command, vfs_path_get_last_path_str (vpath), EXECUTE_INTERNAL);
vfs_path_free (vpath);
return;
}
vfs_path_free (vpath);
/* FIXME: Creation of new files on VFS is not supported */
if (!*filename)
return;
localcopy = mc_getlocalcopy (filename);
if (localcopy == NULL)
{
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"), filename);
vfs_path_free (vpath);
return;
}
localcopy_vpath = mc_getlocalcopy (vpath);
if (localcopy_vpath == NULL)
{
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"), filename);
vfs_path_free (vpath);
return;
}
localcopy_vpath = vfs_path_from_str (localcopy);
/*
* filename can be an entry on panel, it can be changed by executing
* the command, so make a copy. Smarter VFS code would make the code
* below unnecessary.
*/
fn = g_strdup (filename);
mc_stat (localcopy_vpath, &st);
mtime = st.st_mtime;
do_execute (command, localcopy, EXECUTE_INTERNAL);
do_execute (command, vfs_path_get_last_path_str (localcopy_vpath), EXECUTE_INTERNAL);
mc_stat (localcopy_vpath, &st);
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
g_free (localcopy);
mc_ungetlocalcopy (vpath, localcopy_vpath, mtime != st.st_mtime);
vfs_path_free (localcopy_vpath);
g_free (fn);
vfs_path_free (vpath);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -106,7 +106,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
int is_cd = 0;
char buffer[1024];
char *p = 0;
char *localcopy = NULL;
vfs_path_t *localcopy_vpath = NULL;
int do_local_copy;
time_t localmtime = 0;
struct stat mystat;
@ -155,10 +155,10 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
/* User canceled */
fclose (cmd_file);
mc_unlink (file_name_vpath);
if (localcopy)
if (localcopy_vpath != NULL)
{
mc_ungetlocalcopy (filename, localcopy, 0);
g_free (localcopy);
mc_ungetlocalcopy (vpath, localcopy_vpath, FALSE);
vfs_path_free (localcopy_vpath);
}
goto ret;
}
@ -223,20 +223,18 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
{
if (do_local_copy)
{
vfs_path_t *vpath_local;
localcopy = mc_getlocalcopy (filename);
if (localcopy == NULL)
localcopy_vpath = mc_getlocalcopy (vpath);
if (localcopy_vpath == NULL)
{
fclose (cmd_file);
mc_unlink (file_name_vpath);
goto ret;
}
vpath_local = vfs_path_from_str (localcopy);
mc_stat (vpath_local, &mystat);
mc_stat (localcopy_vpath, &mystat);
localmtime = mystat.st_mtime;
text = quote_func (localcopy, 0);
vfs_path_free (vpath_local);
text =
quote_func (vfs_path_get_last_path_str (localcopy_vpath),
0);
}
else
{
@ -382,15 +380,11 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
g_free (cmd);
if (localcopy)
if (localcopy_vpath != NULL)
{
vfs_path_t *vpath_local;
vpath_local = vfs_path_from_str (localcopy);
mc_stat (vpath_local, &mystat);
mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);
vfs_path_free (vpath_local);
g_free (localcopy);
mc_stat (localcopy_vpath, &mystat);
mc_ungetlocalcopy (vpath, localcopy_vpath, localmtime != mystat.st_mtime);
vfs_path_free (localcopy_vpath);
}
ret:
vfs_path_free (file_name_vpath);
@ -512,8 +506,9 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
if (*have_type == 0)
{
vfs_path_t *filename_vpath;
vfs_path_t *localfile_vpath;
char *realname; /* name used with "file" */
char *localfile;
#ifdef HAVE_CHARSET
int got_encoding_data;
@ -522,15 +517,20 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
/* Don't repeate even unsuccessful checks */
*have_type = 1;
localfile = mc_getlocalcopy (filename);
if (localfile == NULL)
filename_vpath = vfs_path_from_str (filename);
localfile_vpath = mc_getlocalcopy (filename_vpath);
if (localfile_vpath == NULL)
{
vfs_path_free (filename_vpath);
return -1;
}
realname = localfile;
realname = vfs_path_get_last_path_str (localfile_vpath);
#ifdef HAVE_CHARSET
got_encoding_data = is_autodetect_codeset_enabled
? get_file_encoding_local (localfile, encoding_id, sizeof (encoding_id)) : 0;
? get_file_encoding_local (vfs_path_get_last_path_str (localfile_vpath), encoding_id,
sizeof (encoding_id)) : 0;
if (got_encoding_data > 0)
{
@ -549,9 +549,12 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
}
#endif /* HAVE_CHARSET */
mc_ungetlocalcopy (filename, localfile, 0);
mc_ungetlocalcopy (filename_vpath, localfile_vpath, FALSE);
vfs_path_free (filename_vpath);
got_data = get_file_type_local (localfile, content_string, sizeof (content_string));
got_data =
get_file_type_local (vfs_path_get_last_path_str (localfile_vpath), content_string,
sizeof (content_string));
if (got_data > 0)
{
@ -583,7 +586,7 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
/* No data */
content_string[0] = '\0';
}
g_free (realname);
vfs_path_free (localfile_vpath);
}
if (got_data == -1)

View File

@ -375,13 +375,15 @@ extfs_free_archive (struct archive *archive)
if (archive->local_name != NULL)
{
struct stat my;
vfs_path_t *tmp_vpath;
vfs_path_t *local_name_vpath, *name_vpath;
tmp_vpath = vfs_path_from_str (archive->local_name);
mc_stat (tmp_vpath, &my);
vfs_path_free (tmp_vpath);
mc_ungetlocalcopy (archive->name, archive->local_name,
local_name_vpath = vfs_path_from_str (archive->local_name);
name_vpath = vfs_path_from_str (archive->local_name);
mc_stat (local_name_vpath, &my);
mc_ungetlocalcopy (name_vpath, local_name_vpath,
archive->local_stat.st_mtime != my.st_mtime);
vfs_path_free (local_name_vpath);
vfs_path_free (name_vpath);
g_free (archive->local_name);
}
g_free (archive->name);
@ -401,32 +403,31 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
struct stat mystat;
struct archive *current_archive;
struct entry *root_entry;
char *local_name = NULL, *tmp = NULL;
vfs_path_t *vpath;
vfs_path_element_t *path_element = NULL;
vpath = vfs_path_from_str (name);
if (vpath != NULL)
path_element = vfs_path_get_by_index (vpath, -1);
char *tmp = NULL;
vfs_path_t *local_name_vpath = NULL;
vfs_path_t *name_vpath;
name_vpath = vfs_path_from_str (name);
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, fstype);
if (info->need_archive)
{
if (mc_stat (vpath, &mystat) == -1)
if (mc_stat (name_vpath, &mystat) == -1)
goto ret;
if (!vfs_file_is_local (vpath))
if (!vfs_file_is_local (name_vpath))
{
local_name = mc_getlocalcopy (name);
if (local_name == NULL)
local_name_vpath = mc_getlocalcopy (name_vpath);
if (local_name_vpath == NULL)
goto ret;
}
tmp = name_quote ((vpath != NULL) ? path_element->path : name, 0);
tmp = name_quote ( vfs_path_get_last_path_str (name_vpath), 0);
}
cmd = g_strconcat (info->path, info->prefix, " list ",
local_name != NULL ? local_name : tmp, (char *) NULL);
vfs_path_get_last_path_str (local_name_vpath) != NULL ?
vfs_path_get_last_path_str (local_name_vpath) : tmp, (char *) NULL);
g_free (tmp);
open_error_pipe ();
@ -435,10 +436,10 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
if (result == NULL)
{
close_error_pipe (D_ERROR, NULL);
if (local_name != NULL)
if (local_name_vpath != NULL)
{
mc_ungetlocalcopy (name, local_name, 0);
g_free (local_name);
mc_ungetlocalcopy (name_vpath, local_name_vpath, FALSE);
vfs_path_free (local_name_vpath);
}
goto ret;
}
@ -450,13 +451,12 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
current_archive = g_new (struct archive, 1);
current_archive->fstype = fstype;
current_archive->name = (name != NULL) ? g_strdup (name) : NULL;
current_archive->local_name = local_name;
current_archive->local_name = g_strdup (vfs_path_get_last_path_str (local_name_vpath));
if (local_name != NULL)
if (local_name_vpath != NULL)
{
vfs_path_t *tmp_vpath = vfs_path_from_str (local_name);
mc_stat (tmp_vpath, &current_archive->local_stat);
vfs_path_free (tmp_vpath);
mc_stat (local_name_vpath, &current_archive->local_stat);
vfs_path_free (local_name_vpath);
}
current_archive->inode_counter = 0;
current_archive->fd_usage = 0;
@ -482,7 +482,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
*pparc = current_archive;
ret:
vfs_path_free (vpath);
vfs_path_free (name_vpath);
return result;
}
@ -1503,11 +1503,11 @@ extfs_free (vfsid id)
/* --------------------------------------------------------------------------------------------- */
static char *
static vfs_path_t *
extfs_getlocalcopy (const vfs_path_t * vpath)
{
struct pseudofile *fp;
char *p;
vfs_path_t *p;
fp = (struct pseudofile *) extfs_open (vpath, O_RDONLY, 0);
if (fp == NULL)
@ -1517,7 +1517,7 @@ extfs_getlocalcopy (const vfs_path_t * vpath)
extfs_close ((void *) fp);
return NULL;
}
p = g_strdup (fp->entry->inode->local_filename);
p = vfs_path_from_str (fp->entry->inode->local_filename);
fp->archive->fd_usage++;
extfs_close ((void *) fp);
return p;
@ -1526,7 +1526,7 @@ extfs_getlocalcopy (const vfs_path_t * vpath)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
extfs_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboolean has_changed)
{
struct pseudofile *fp;
@ -1534,10 +1534,10 @@ extfs_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_chang
if (fp == NULL)
return 0;
if (strcmp (fp->entry->inode->local_filename, local) == 0)
if (strcmp (fp->entry->inode->local_filename, vfs_path_get_last_path_str (local)) == 0)
{
fp->archive->fd_usage--;
if (has_changed != 0)
if (has_changed)
fp->has_changed = TRUE;
extfs_close ((void *) fp);
return 0;

View File

@ -294,18 +294,16 @@ local_rmdir (const vfs_path_t * vpath)
/* --------------------------------------------------------------------------------------------- */
static char *
static vfs_path_t *
local_getlocalcopy (const vfs_path_t * vpath)
{
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1);
return g_strdup (path_element->path);
return vfs_path_clone (vpath);
}
/* --------------------------------------------------------------------------------------------- */
static int
local_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
local_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboolean has_changed)
{
(void) vpath;
(void) local;

View File

@ -74,7 +74,7 @@
return -1; \
} \
else \
*t++ = *s;
*t++ = *s_iter;
#define COPY_STRING(a) \
if ((t - pad) + strlen(a) > sizeof(pad)) \
@ -124,52 +124,58 @@ sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
{
int w;
char pad[10240];
char *s, *t = pad;
char *s_iter, *t = pad;
int was_percent = 0;
char *pname; /* name of parent archive */
vfs_path_t *pname, *s; /* name of parent archive */
char *pqname; /* name of parent archive, quoted */
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
pname = vfs_path_to_str_elements_count (vpath, -1);
pname = vfs_path_clone (vpath);
vfs_path_remove_element_by_index (pname, -1);
w = (*path_element->class->which) (path_element->class, path_element->vfs_prefix);
if (w == -1)
vfs_die ("This cannot happen... Hopefully.\n");
if (!(sfs_flags[w] & F_1) && strcmp (pname, "/"))
if ((sfs_flags[w] & F_1) == 0 && strcmp (vfs_path_get_last_path_str (pname), PATH_SEP_STR) != 0)
{
g_free (pname);
vfs_path_free (pname);
return -1;
}
/* if ((sfs_flags[w] & F_2) || (!inpath) || (!*inpath)); else return -1; */
if (!(sfs_flags[w] & F_NOLOCALCOPY))
if ((sfs_flags[w] & F_NOLOCALCOPY) == 0)
{
s = mc_getlocalcopy (pname);
if (!s)
if (s == NULL)
{
g_free (pname);
vfs_path_free (pname);
return -1;
}
pqname = name_quote (s, 0);
g_free (s);
pqname = name_quote (vfs_path_get_last_path_str (s), 0);
vfs_path_free (s);
}
else
{
pqname = name_quote (pname, 0);
char *pname_str;
pname_str = vfs_path_to_str (pname);
pqname = name_quote (pname_str, 0);
g_free (pname_str);
}
g_free (pname);
vfs_path_free (pname);
for (s = sfs_command[w]; *s; s++)
for (s_iter = sfs_command[w]; *s_iter != '\0'; s_iter++)
{
if (was_percent)
{
const char *ptr = NULL;
was_percent = 0;
switch (*s)
switch (*s_iter)
{
case '1':
ptr = pqname;
@ -193,7 +199,7 @@ sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
}
else
{
if (*s == '%')
if (*s_iter == '%')
was_percent = 1;
else
COPY_CHAR;
@ -392,16 +398,16 @@ sfs_nothingisopen (vfsid id)
/* --------------------------------------------------------------------------------------------- */
static char *
static vfs_path_t *
sfs_getlocalcopy (const vfs_path_t * vpath)
{
return g_strdup (sfs_redirect (vpath));
return vfs_path_from_str (sfs_redirect (vpath));
}
/* --------------------------------------------------------------------------------------------- */
static int
sfs_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
sfs_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboolean has_changed)
{
(void) vpath;
(void) local;