mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
* vfs.h: Constify chdir() and opendir() methods. Adjust all
dependencies. * vfs.c (mc_chdir): Constify, eliminate protection against broken implementations of chdir() method. (mc_opendir): Constify.
This commit is contained in:
parent
4b5a2a0b62
commit
30c4bd1b6d
@ -1,5 +1,11 @@
|
||||
2003-11-13 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* vfs.h: Constify chdir() and opendir() methods. Adjust all
|
||||
dependencies.
|
||||
* vfs.c (mc_chdir): Constify, eliminate protection against
|
||||
broken implementations of chdir() method.
|
||||
(mc_opendir): Constify.
|
||||
|
||||
* direntry.c (vfs_s_stamp_me): Generalize and move ...
|
||||
* gc.c (vfs_stamp_create): ... here. Use whenever possible.
|
||||
|
||||
|
@ -561,7 +561,7 @@ struct dirhandle {
|
||||
};
|
||||
|
||||
static void *
|
||||
vfs_s_opendir (struct vfs_class *me, char *dirname)
|
||||
vfs_s_opendir (struct vfs_class *me, const char *dirname)
|
||||
{
|
||||
struct vfs_s_inode *dir;
|
||||
struct dirhandle *info;
|
||||
@ -618,7 +618,7 @@ vfs_s_closedir (void *data)
|
||||
}
|
||||
|
||||
static int
|
||||
vfs_s_chdir (struct vfs_class *me, char *path)
|
||||
vfs_s_chdir (struct vfs_class *me, const char *path)
|
||||
{
|
||||
void *data;
|
||||
if (!(data = vfs_s_opendir (me, path)))
|
||||
|
@ -854,7 +854,7 @@ static int extfs_errno (struct vfs_class *me)
|
||||
return my_errno;
|
||||
}
|
||||
|
||||
static void * extfs_opendir (struct vfs_class *me, char *dirname)
|
||||
static void * extfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q;
|
||||
@ -1071,7 +1071,7 @@ static int extfs_rmdir (struct vfs_class *me, char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int extfs_chdir (struct vfs_class *me, char *path)
|
||||
static int extfs_chdir (struct vfs_class *me, const char *path)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q;
|
||||
|
@ -74,7 +74,7 @@ local_errno (struct vfs_class *me)
|
||||
}
|
||||
|
||||
static void *
|
||||
local_opendir (struct vfs_class *me, char *dirname)
|
||||
local_opendir (struct vfs_class *me, const char *dirname)
|
||||
{
|
||||
DIR **local_info;
|
||||
DIR *dir;
|
||||
@ -193,7 +193,7 @@ local_rename (struct vfs_class *me, char *a, char *b)
|
||||
}
|
||||
|
||||
static int
|
||||
local_chdir (struct vfs_class *me, char *path)
|
||||
local_chdir (struct vfs_class *me, const char *path)
|
||||
{
|
||||
return chdir (path);
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ typedef struct {
|
||||
} opendir_info;
|
||||
|
||||
static void *
|
||||
mcfs_opendir (struct vfs_class *me, char *dirname)
|
||||
mcfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
{
|
||||
opendir_info *mcfs_info;
|
||||
mcfs_connection *mc;
|
||||
@ -1011,7 +1011,7 @@ mcfs_rename (struct vfs_class *me, char *a, char *b)
|
||||
}
|
||||
|
||||
static int
|
||||
mcfs_chdir (struct vfs_class *me, char *path)
|
||||
mcfs_chdir (struct vfs_class *me, const char *path)
|
||||
{
|
||||
char *remote_dir;
|
||||
mcfs_connection *mc;
|
||||
|
16
vfs/smbfs.c
16
vfs/smbfs.c
@ -1187,7 +1187,7 @@ is_error (int result, int errno_num)
|
||||
#endif
|
||||
|
||||
static void *
|
||||
smbfs_opendir (struct vfs_class *me, char *dirname)
|
||||
smbfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
{
|
||||
opendir_info *smbfs_info;
|
||||
smbfs_connection *sc;
|
||||
@ -1436,16 +1436,16 @@ smbfs_get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
}
|
||||
|
||||
static int
|
||||
smbfs_chdir (struct vfs_class *me, char *path)
|
||||
smbfs_chdir (struct vfs_class *me, const char *path)
|
||||
{
|
||||
char *remote_dir;
|
||||
smbfs_connection *sc;
|
||||
|
||||
DEBUG(3, ("smbfs_chdir(path:%s)\n", path));
|
||||
char *remote_dir;
|
||||
smbfs_connection *sc;
|
||||
|
||||
DEBUG (3, ("smbfs_chdir(path:%s)\n", path));
|
||||
if (!(remote_dir = smbfs_get_path (&sc, path)))
|
||||
return -1;
|
||||
return -1;
|
||||
g_free (remote_dir);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
20
vfs/vfs.c
20
vfs/vfs.c
@ -453,17 +453,18 @@ mc_close (int handle)
|
||||
}
|
||||
|
||||
DIR *
|
||||
mc_opendir (char *dirname)
|
||||
mc_opendir (const char *dirname)
|
||||
{
|
||||
int handle, *handlep;
|
||||
void *info;
|
||||
struct vfs_class *vfs;
|
||||
char *dname;
|
||||
|
||||
dirname = vfs_canon (dirname);
|
||||
vfs = vfs_get_class (dirname);
|
||||
dname = vfs_canon (dirname);
|
||||
vfs = vfs_get_class (dname);
|
||||
|
||||
info = vfs->opendir ? (*vfs->opendir)(vfs, dirname) : NULL;
|
||||
g_free (dirname);
|
||||
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
|
||||
g_free (dname);
|
||||
if (!info){
|
||||
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
|
||||
return NULL;
|
||||
@ -663,9 +664,9 @@ vfs_canon (const char *path)
|
||||
* Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
mc_chdir (char *path)
|
||||
mc_chdir (const char *path)
|
||||
{
|
||||
char *new_dir, *new_dir_copy;
|
||||
char *new_dir;
|
||||
struct vfs_class *old_vfs, *new_vfs;
|
||||
vfsid old_vfsid;
|
||||
struct vfs_stamping *parent;
|
||||
@ -676,10 +677,7 @@ mc_chdir (char *path)
|
||||
if (!new_vfs->chdir)
|
||||
return -1;
|
||||
|
||||
/* new_vfs->chdir can write to the second argument, use a copy */
|
||||
new_dir_copy = g_strdup (new_dir);
|
||||
result = (*new_vfs->chdir) (new_vfs, new_dir_copy);
|
||||
g_free (new_dir_copy);
|
||||
result = (*new_vfs->chdir) (new_vfs, new_dir);
|
||||
|
||||
if (result == -1) {
|
||||
errno = ferrno (new_vfs);
|
||||
|
@ -33,7 +33,7 @@ struct vfs_class {
|
||||
int (*read) (void *vfs_info, char *buffer, int count);
|
||||
int (*write) (void *vfs_info, char *buf, int count);
|
||||
|
||||
void *(*opendir) (struct vfs_class *me, char *dirname);
|
||||
void *(*opendir) (struct vfs_class *me, const char *dirname);
|
||||
void *(*readdir) (void *vfs_info);
|
||||
int (*closedir) (void *vfs_info);
|
||||
|
||||
@ -52,7 +52,7 @@ struct vfs_class {
|
||||
int (*link) (struct vfs_class *me, char *p1, char *p2);
|
||||
int (*unlink) (struct vfs_class *me, char *path);
|
||||
int (*rename) (struct vfs_class *me, char *p1, char *p2);
|
||||
int (*chdir) (struct vfs_class *me, char *path);
|
||||
int (*chdir) (struct vfs_class *me, const char *path);
|
||||
int (*ferrno) (struct vfs_class *me);
|
||||
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
||||
@ -138,9 +138,9 @@ int mc_close (int handle);
|
||||
int mc_read (int handle, char *buffer, int count);
|
||||
int mc_write (int handle, char *buffer, int count);
|
||||
off_t mc_lseek (int fd, off_t offset, int whence);
|
||||
int mc_chdir (char *);
|
||||
int mc_chdir (const char *path);
|
||||
|
||||
DIR *mc_opendir (char *dirname);
|
||||
DIR *mc_opendir (const char *dirname);
|
||||
struct dirent *mc_readdir (DIR * dirp);
|
||||
int mc_closedir (DIR * dir);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user