Const-ified the mc_* functions.
Этот коммит содержится в:
родитель
b17b1ac213
Коммит
3cf53917e1
37
vfs/vfs.c
37
vfs/vfs.c
@ -341,24 +341,24 @@ int mc_##name inarg \
|
|||||||
{ \
|
{ \
|
||||||
struct vfs_class *vfs; \
|
struct vfs_class *vfs; \
|
||||||
int result; \
|
int result; \
|
||||||
path = vfs_canon (path); \
|
char *mpath = vfs_canon (path); \
|
||||||
vfs = vfs_get_class (path); \
|
vfs = vfs_get_class (mpath); \
|
||||||
result = vfs->name ? (*vfs->name)callarg : -1; \
|
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||||
g_free (path); \
|
g_free (mpath); \
|
||||||
if (result == -1) \
|
if (result == -1) \
|
||||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||||
return result; \
|
return result; \
|
||||||
}
|
}
|
||||||
|
|
||||||
MC_NAMEOP (chmod, (char *path, int mode), (vfs, path, mode))
|
MC_NAMEOP (chmod, (const char *path, int mode), (vfs, path, mode))
|
||||||
MC_NAMEOP (chown, (char *path, int owner, int group), (vfs, path, owner, group))
|
MC_NAMEOP (chown, (const char *path, int owner, int group), (vfs, path, owner, group))
|
||||||
MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, path, times))
|
MC_NAMEOP (utime, (const char *path, struct utimbuf *times), (vfs, path, times))
|
||||||
MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz))
|
MC_NAMEOP (readlink, (const char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz))
|
||||||
MC_NAMEOP (unlink, (char *path), (vfs, path))
|
MC_NAMEOP (unlink, (const char *path), (vfs, path))
|
||||||
MC_NAMEOP (symlink, (char *name1, char *path), (vfs, name1, path))
|
MC_NAMEOP (symlink, (const char *name1, const char *path), (vfs, name1, path))
|
||||||
MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs, path, mode))
|
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (vfs, path, mode))
|
||||||
MC_NAMEOP (rmdir, (char *path), (vfs, path))
|
MC_NAMEOP (rmdir, (const char *path), (vfs, path))
|
||||||
MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs, path, mode, dev))
|
MC_NAMEOP (mknod, (const char *path, int mode, int dev), (vfs, path, mode, dev))
|
||||||
|
|
||||||
|
|
||||||
#define MC_HANDLEOP(name, inarg, callarg) \
|
#define MC_HANDLEOP(name, inarg, callarg) \
|
||||||
@ -376,7 +376,7 @@ int mc_##name inarg \
|
|||||||
}
|
}
|
||||||
|
|
||||||
MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) )
|
MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) )
|
||||||
MC_HANDLEOP (write, (int handle, char *buf, int nbyte), (vfs_info (handle), buf, nbyte))
|
MC_HANDLEOP (write, (int handle, const char *buf, int nbyte), (vfs_info (handle), buf, nbyte))
|
||||||
|
|
||||||
|
|
||||||
#define MC_RENAMEOP(name) \
|
#define MC_RENAMEOP(name) \
|
||||||
@ -414,18 +414,19 @@ mc_ctl (int handle, int ctlop, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_setctl (char *path, int ctlop, void *arg)
|
mc_setctl (const char *path, int ctlop, void *arg)
|
||||||
{
|
{
|
||||||
struct vfs_class *vfs;
|
struct vfs_class *vfs;
|
||||||
int result;
|
int result;
|
||||||
|
char *mpath;
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
vfs_die("You don't want to pass NULL to mc_setctl.");
|
vfs_die("You don't want to pass NULL to mc_setctl.");
|
||||||
|
|
||||||
path = vfs_canon (path);
|
mpath = vfs_canon (path);
|
||||||
vfs = vfs_get_class (path);
|
vfs = vfs_get_class (mpath);
|
||||||
result = vfs->setctl ? (*vfs->setctl)(vfs, path, ctlop, arg) : 0;
|
result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0;
|
||||||
g_free (path);
|
g_free (mpath);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
vfs/vfs.h
22
vfs/vfs.h
@ -137,7 +137,7 @@ extern int use_netrc;
|
|||||||
int mc_open (const char *filename, int flags, ...);
|
int mc_open (const char *filename, int flags, ...);
|
||||||
int mc_close (int handle);
|
int mc_close (int handle);
|
||||||
int mc_read (int handle, char *buffer, int count);
|
int mc_read (int handle, char *buffer, int count);
|
||||||
int mc_write (int handle, char *buffer, int count);
|
int mc_write (int handle, const char *buffer, int count);
|
||||||
off_t mc_lseek (int fd, off_t offset, int whence);
|
off_t mc_lseek (int fd, off_t offset, int whence);
|
||||||
int mc_chdir (const char *path);
|
int mc_chdir (const char *path);
|
||||||
|
|
||||||
@ -149,22 +149,22 @@ int mc_stat (const char *path, struct stat *buf);
|
|||||||
int mc_lstat (const char *path, struct stat *buf);
|
int mc_lstat (const char *path, struct stat *buf);
|
||||||
int mc_fstat (int fd, struct stat *buf);
|
int mc_fstat (int fd, struct stat *buf);
|
||||||
|
|
||||||
int mc_chmod (char *path, int mode);
|
int mc_chmod (const char *path, int mode);
|
||||||
int mc_chown (char *path, int owner, int group);
|
int mc_chown (const char *path, int owner, int group);
|
||||||
int mc_utime (char *path, struct utimbuf *times);
|
int mc_utime (const char *path, struct utimbuf *times);
|
||||||
int mc_readlink (char *path, char *buf, int bufsiz);
|
int mc_readlink (const char *path, char *buf, int bufsiz);
|
||||||
int mc_unlink (char *path);
|
int mc_unlink (const char *path);
|
||||||
int mc_symlink (char *name1, char *name2);
|
int mc_symlink (const char *name1, const char *name2);
|
||||||
int mc_link (const char *name1, const char *name2);
|
int mc_link (const char *name1, const char *name2);
|
||||||
int mc_mknod (char *, int, int);
|
int mc_mknod (const char *, int, int);
|
||||||
int mc_rename (const char *original, const char *target);
|
int mc_rename (const char *original, const char *target);
|
||||||
int mc_rmdir (char *path);
|
int mc_rmdir (const char *path);
|
||||||
int mc_mkdir (char *path, mode_t mode);
|
int mc_mkdir (const char *path, mode_t mode);
|
||||||
|
|
||||||
char *mc_getlocalcopy (const char *pathname);
|
char *mc_getlocalcopy (const char *pathname);
|
||||||
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
|
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
|
||||||
int mc_ctl (int fd, int ctlop, void *arg);
|
int mc_ctl (int fd, int ctlop, void *arg);
|
||||||
int mc_setctl (char *path, int ctlop, void *arg);
|
int mc_setctl (const char *path, int ctlop, void *arg);
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t);
|
caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t);
|
||||||
int mc_munmap (caddr_t addr, size_t len);
|
int mc_munmap (caddr_t addr, size_t len);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user