Added type for VFS class flags.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-07-08 14:24:58 +04:00
parent 3ef8854036
commit 57281c6e0b
4 changed files with 23 additions and 14 deletions

View File

@ -33,7 +33,7 @@ typedef void (*fill_names_f) (const char *);
struct vfs_class {
struct vfs_class *next;
const char *name; /* "FIles over SHell" */
int flags;
vfs_class_flags_t flags;
const char *prefix; /* "fish:" */
void *data; /* this is for filesystem's own use */
int verrno; /* can't use errno because glibc2 might define errno as function */

View File

@ -1157,15 +1157,15 @@ mc_chdir (const char *path)
}
}
/* Return 1 is the current VFS class is local */
int
/* Return TRUE is the current VFS class is local */
gboolean
vfs_current_is_local (void)
{
return (current_vfs->flags & VFSF_LOCAL) != 0;
}
/* Return flags of the VFS class of the given filename */
int
vfs_class_flags_t
vfs_file_class_flags (const char *filename)
{
struct vfs_class *vfs;
@ -1173,7 +1173,7 @@ vfs_file_class_flags (const char *filename)
fname = vfs_canon_and_translate (filename);
if (fname == NULL)
return -1;
return VFSF_UNKNOWN;
vfs = vfs_get_class (fname);
g_free (fname);
@ -1420,8 +1420,8 @@ vfs_translate_url (const char *url)
return g_strdup (url);
}
int
gboolean
vfs_file_is_local (const char *filename)
{
return vfs_file_class_flags (filename) & VFSF_LOCAL;
return (vfs_file_class_flags (filename) & VFSF_LOCAL) != 0;
}

View File

@ -12,9 +12,15 @@
#include <utime.h>
#include <stdio.h>
#include "lib/global.h"
/* Flags of VFS classes */
#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
#define VFSF_NOLINKS 2 /* Hard links not supported */
typedef enum
{
VFSF_UNKNOWN = 0,
VFSF_LOCAL = 1 << 0, /* Class is local (not virtual) filesystem */
VFSF_NOLINKS = 1 << 1 /* Hard links not supported */
} vfs_class_flags_t;
#ifdef ENABLE_VFS
@ -27,8 +33,8 @@ extern int use_netrc;
void vfs_init (void);
void vfs_shut (void);
int vfs_current_is_local (void);
int vfs_file_is_local (const char *filename);
gboolean vfs_current_is_local (void);
gboolean vfs_file_is_local (const char *filename);
ssize_t mc_read (int handle, void *buffer, size_t count);
ssize_t mc_write (int handle, const void *buffer, size_t count);
int mc_utime (const char *path, struct utimbuf *times);
@ -61,6 +67,9 @@ char *mc_getlocalcopy (const char *pathname);
char *vfs_strip_suffix_from_filename (const char *filename);
char *vfs_translate_url (const char *url);
struct vfs_class *vfs_get_class (const char *path);
vfs_class_flags_t vfs_file_class_flags (const char *filename);
/* return encoding after last #enc: or NULL, if part does not contain #enc:
* return static buffer */
const char *vfs_get_encoding (const char *path);
@ -77,8 +86,8 @@ char *vfs_canon_and_translate (const char *path);
#define vfs_init() do { } while (0)
#define vfs_shut() do { } while (0)
#define vfs_current_is_local() (1)
#define vfs_file_is_local(x) (1)
#define vfs_current_is_local() (TRUE)
#define vfs_file_is_local(x) (TRUE)
#define vfs_strip_suffix_from_filename(x) g_strdup(x)
#define vfs_get_class(x) (struct vfs_class *)(NULL)
#define vfs_translate_url(s) g_strdup(s)

View File

@ -225,7 +225,7 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat)
struct stat link_stat;
const char *p;
if (vfs_file_class_flags (src_name) & VFSF_NOLINKS)
if ((vfs_file_class_flags (src_name) & VFSF_NOLINKS) != 0)
return 0;
for (lp = linklist; lp != NULL; lp = lp->next)