mirror of https://github.com/MidnightCommander/mc
Ticket #2361: VFS URI reimplementation
Code cleanup: * (vfs_set_raw_current_dir): remove redundant check. * VFS: minor optimizations. * Fixed type of mode argument of vfs_class:chmod method. Signed-off-by: Andrew Borodin <aborodin@vmail.ru> Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
92d21199c4
commit
ea4078e52e
|
@ -269,8 +269,7 @@ mc_symlink (const char *name1, const char *path)
|
|||
|
||||
if (vpath2 != NULL)
|
||||
{
|
||||
vfs_path_element_t *path_element =
|
||||
vfs_path_get_by_index (vpath1, vfs_path_elements_count (vpath1) - 1);
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath1, -1);
|
||||
if (vfs_path_element_valid (path_element))
|
||||
{
|
||||
result =
|
||||
|
@ -330,8 +329,8 @@ int mc_##name (const char *fname1, const char *fname2) \
|
|||
vfs_path_free(vpath1); \
|
||||
return -1; \
|
||||
}\
|
||||
path_element1 = vfs_path_get_by_index (vpath1, vfs_path_elements_count (vpath1) - 1); \
|
||||
path_element2 = vfs_path_get_by_index (vpath2, vfs_path_elements_count (vpath2) - 1); \
|
||||
path_element1 = vfs_path_get_by_index (vpath1, - 1); \
|
||||
path_element2 = vfs_path_get_by_index (vpath2, - 1); \
|
||||
\
|
||||
if (!vfs_path_element_valid (path_element1) || !vfs_path_element_valid (path_element2) || \
|
||||
path_element1->class != path_element2->class) \
|
||||
|
|
|
@ -664,10 +664,7 @@ vfs_path_new (void)
|
|||
int
|
||||
vfs_path_elements_count (const vfs_path_t * vpath)
|
||||
{
|
||||
if (vpath == NULL)
|
||||
return 0;
|
||||
|
||||
return (vpath->path != NULL) ? g_list_length (vpath->path) : 0;
|
||||
return (vpath != NULL && vpath->path != NULL) ? g_list_length (vpath->path) : 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -683,19 +680,13 @@ vfs_path_elements_count (const vfs_path_t * vpath)
|
|||
vfs_path_element_t *
|
||||
vfs_path_get_by_index (const vfs_path_t * vpath, int element_index)
|
||||
{
|
||||
vfs_path_element_t *element;
|
||||
|
||||
if (vpath == NULL)
|
||||
return NULL;
|
||||
if (element_index < 0)
|
||||
element_index += vfs_path_elements_count (vpath);
|
||||
|
||||
if (element_index < 0)
|
||||
element_index = vfs_path_elements_count (vpath) + element_index;
|
||||
|
||||
element = g_list_nth_data (vpath->path, element_index);
|
||||
if (element == NULL)
|
||||
vfs_die ("vfs_path_get_by_index: incorrect index!");
|
||||
|
||||
return element;
|
||||
return g_list_nth_data (vpath->path, element_index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -33,8 +33,6 @@ typedef struct
|
|||
GIConv converter;
|
||||
DIR *info;
|
||||
} dir;
|
||||
|
||||
struct vfs_s_super *current_super_block;
|
||||
} vfs_path_element_t;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
|
|
@ -379,8 +379,7 @@ vfs_get_raw_current_dir (void)
|
|||
void
|
||||
vfs_set_raw_current_dir (const vfs_path_t * vpath)
|
||||
{
|
||||
if (current_path != NULL)
|
||||
vfs_path_free (current_path);
|
||||
vfs_path_free (current_path);
|
||||
current_path = (vfs_path_t *) vpath;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ typedef struct vfs_class
|
|||
int (*lstat) (const vfs_path_t * vpath, struct stat * buf);
|
||||
int (*fstat) (void *vfs_info, struct stat * buf);
|
||||
|
||||
int (*chmod) (const vfs_path_t * vpath, int mode);
|
||||
int (*chmod) (const vfs_path_t * vpath, mode_t mode);
|
||||
int (*chown) (const vfs_path_t * vpath, uid_t owner, gid_t group);
|
||||
int (*utime) (const vfs_path_t * vpath, struct utimbuf * times);
|
||||
|
||||
|
|
|
@ -1177,7 +1177,7 @@ extfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_chmod (const vfs_path_t * vpath, int mode)
|
||||
extfs_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
(void) vpath;
|
||||
(void) mode;
|
||||
|
|
|
@ -1244,7 +1244,7 @@ fish_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
fish_chmod (const vfs_path_t * vpath, int mode)
|
||||
fish_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
gchar *shell_commands = NULL;
|
||||
char buf[BUF_LARGE];
|
||||
|
@ -1262,7 +1262,7 @@ fish_chmod (const vfs_path_t * vpath, int mode)
|
|||
|
||||
shell_commands = g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILEMODE=%4.4o;\n",
|
||||
SUP->scr_chmod, (char *) NULL);
|
||||
g_snprintf (buf, sizeof (buf), shell_commands, rpath, mode & 07777);
|
||||
g_snprintf (buf, sizeof (buf), shell_commands, rpath, (int) (mode & 07777));
|
||||
g_free (shell_commands);
|
||||
g_free (rpath);
|
||||
return fish_send_command (path_element->class, super, buf, OPT_FLUSH);
|
||||
|
|
|
@ -1981,12 +1981,12 @@ ftpfs_send_command (const vfs_path_t * vpath, const char *cmd, int flags)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
ftpfs_chmod (const vfs_path_t * vpath, int mode)
|
||||
ftpfs_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
char buf[BUF_SMALL];
|
||||
int ret;
|
||||
|
||||
g_snprintf (buf, sizeof (buf), "SITE CHMOD %4.4o /%%s", mode & 07777);
|
||||
g_snprintf (buf, sizeof (buf), "SITE CHMOD %4.4o /%%s", (int) (mode & 07777));
|
||||
|
||||
ret = ftpfs_send_command (vpath, buf, OPT_FLUSH);
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ local_lstat (const vfs_path_t * vpath, struct stat *buf)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
local_chmod (const vfs_path_t * vpath, int mode)
|
||||
local_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ sfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
sfs_chmod (const vfs_path_t * vpath, int mode)
|
||||
sfs_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
return chmod (sfs_redirect (vpath), mode);
|
||||
}
|
||||
|
|
|
@ -964,11 +964,11 @@ smbfs_closedir (void *info)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
smbfs_chmod (const vfs_path_t * vpath, int mode)
|
||||
smbfs_chmod (const vfs_path_t * vpath, mode_t mode)
|
||||
{
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", path_element->path, mode));
|
||||
DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", path_element->path, (int) mode));
|
||||
/* my_errno = EOPNOTSUPP;
|
||||
return -1; *//* cannot chmod on smb filesystem */
|
||||
return 0; /* make mc happy */
|
||||
|
|
Loading…
Reference in New Issue