capfuse_captive_file_info_object.c \
capfuse_captive_file_info_object.h \
main.c \
- main.h
+ main.h \
+ utf8.c \
+ utf8.h
mount_captive_CFLAGS= $(GNOME_VFS_CFLAGS) $(LIBXML_CFLAGS) $(FUSE_CFLAGS)
mount_captive_LDADD =$(captive_library) $(GNOME_VFS_LIBS) $(LIBXML_LIBS) $(FUSE_LIBS) $(INTLLIBS)
mount_captive_LDFLAGS=$(READLINE_LDFLAGS)
#include "op_chmod.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_chmod(const char *path,mode_t mode)
&& !S_ISDIR(mode))
return -EPERM;
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
/* Do not: GNOME_VFS_OPEN_WRITE
* as we would get EPERM for setting back: chmod u+w
*/
#include "main.h"
#include "gnomevfsresult.h"
#include "capfuse_captive_file_info_object.h"
+#include "utf8.h"
int op_getattr(const char *path,struct stat *buf)
g_return_val_if_fail(path!=NULL,-EINVAL);
g_return_val_if_fail(buf!=NULL,-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,0)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "op_mkdir.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_mkdir(const char *path,mode_t mode)
if (mode&S_IFMT)
return -EPERM;
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_directory_new_make(&captive_directory_object,capfuse_captive_vfs_object,
path, /* pathname */
mode))) /* perm */
#include "op_mknod.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_mknod(const char *path,mode_t mode,dev_t rdev)
if (!S_ISREG(mode))
return -EPERM;
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_create(&captive_file_object,capfuse_captive_vfs_object,
path, /* pathname */
0, /* mode */
#include "op_open.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_open(const char *path,struct fuse_file_info *fi)
g_return_val_if_fail(sizeof(fi->fh)==sizeof(unsigned long),-EINVAL);
g_return_val_if_fail(sizeof(fi->fh)>=sizeof(CaptiveFileObject *),-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
GNOME_VFS_OPEN_RANDOM
|| (!(fi->flags&(O_RDONLY|O_RDWR)) ? 0 : GNOME_VFS_OPEN_READ)
#include "op_opendir.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_opendir(const char *path,struct fuse_file_info *fi)
g_return_val_if_fail(sizeof(fi->fh)==sizeof(unsigned long),-EINVAL);
g_return_val_if_fail(sizeof(fi->fh)>=sizeof(CaptiveDirectoryObject *),-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_directory_new_open(&captive_directory_object,capfuse_captive_vfs_object,path)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "main.h"
#include "gnomevfsresult.h"
#include "capfuse_captive_file_info_object.h"
+#include "utf8.h"
/* int (*fuse_fill_dir_t)(void *buf,const char *name,const struct stat *stbuf,off_t off); */
&captive_file_info_object))) { /* captive_file_info_object */
struct stat stat;
int errint;
+char *captive_file_info_object_name;
errint=capfuse_captive_file_info_object_to_stat(&stat,captive_file_info_object);
if (errint) {
g_object_unref(captive_file_info_object);
return errint;
}
+ captive_file_info_object_name=capfuse_filename_from_utf8_malloc_errorchecking(captive_file_info_object->p.name);
errint=(*fill_dir)(
buf, /* buf; opaque */
- captive_file_info_object->p.name, /* name */
+ (captive_file_info_object_name ? captive_file_info_object_name : captive_file_info_object->p.name), /* name */
&stat, /* stbuf */
0); /* off; operation mode 1 - <fuse.h>/(*readdir) */
+ g_free(captive_file_info_object_name); /* may be NULL */
/* WARNING: (*fill_dir) needs: *captive_file_info_object->p.name */
g_object_unref(captive_file_info_object);
if (errint) {
#include "op_rename.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_rename(const char *oldpath,const char *newpath)
g_return_val_if_fail(oldpath!=NULL,-EINVAL);
g_return_val_if_fail(newpath!=NULL,-EINVAL);
+ oldpath=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(oldpath);
+ newpath=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(newpath);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,oldpath,
GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "op_rmdir.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_rmdir(const char *path)
g_return_val_if_fail(path!=NULL,-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_directory_new_open(&captive_directory_object,capfuse_captive_vfs_object,path)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "op_truncate.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_truncate(const char *path,off_t size)
g_return_val_if_fail(path!=NULL,-EINVAL);
g_return_val_if_fail(size>=0,-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "op_unlink.h" /* self */
#include "main.h"
#include "gnomevfsresult.h"
+#include "utf8.h"
int op_unlink(const char *path)
g_return_val_if_fail(path!=NULL,-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
return -gnomevfsresult_to_errno(errvfsresult);
#include "main.h"
#include "gnomevfsresult.h"
#include "capfuse_captive_file_info_object.h"
+#include "utf8.h"
int op_utime(const char *path,struct utimbuf *buf)
g_return_val_if_fail(buf->actime!=0,-EINVAL);
g_return_val_if_fail(buf->modtime!=0,-EINVAL);
+ path=CAPFUSE_FILENAME_TO_UTF8_ALLOCA(path);
+
if (GNOME_VFS_OK!=(errvfsresult=captive_file_new_open(&captive_file_object,capfuse_captive_vfs_object,path,
GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
return -gnomevfsresult_to_errno(errvfsresult);
--- /dev/null
+/* $Id$
+ * FUSE interface module utf8 conversions for libcaptive
+ * Copyright (C) 2003-2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "config.h"
+
+#include "utf8.h" /* self */
+#include <glib/gmessages.h>
+#include <glib/gerror.h>
+#include <glib/gconvert.h>
+#include <glib/gunicode.h>
+
+
+char *capfuse_filename_to_utf8_malloc_errorchecking(const char *name)
+{
+GError *error;
+char *r;
+
+ g_return_val_if_fail(name!=NULL,NULL);
+
+ error=NULL;
+ r=g_filename_to_utf8(
+ name, /* opsysstring */
+ -1, /* len; '\0'-terminated */
+ NULL, /* bytes_read */
+ NULL, /* bytes_written */
+ &error); /* error */
+ if (error) {
+ g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING,
+ _("captive-FUSE %s(): name=\"%s\": %s (see locale(7) and mount(8) environment variables)"),
+ "g_filename_to_utf8",name,error->message);
+ g_clear_error(&error);
+ }
+ return r;
+}
+
+
+char *capfuse_filename_from_utf8_malloc_errorchecking(const char *name)
+{
+GError *error;
+char *r;
+
+ g_return_val_if_fail(name!=NULL,NULL);
+
+ error=NULL;
+ r=g_filename_from_utf8(
+ name, /* utf8string */
+ -1, /* len; '\0'-terminated */
+ NULL, /* bytes_read */
+ NULL, /* bytes_written */
+ &error); /* error */
+ if (error) {
+const gchar *charset;
+
+ g_get_charset(&charset);
+ g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING,"captive-FUSE %s(): name=\"%s\"; g_get_charset()=\"%s\", %s: %s",
+ "g_filename_from_utf8",name,charset,
+ _("see environment variables - locale(7), mount(8) and locale(1) commands \"locale\" and \"locale -a\""),
+ error->message);
+ g_clear_error(&error);
+ }
+ return r;
+}
--- /dev/null
+/* $Id$
+ * Include file for FUSE interface module utf8 conversions for libcaptive
+ * Copyright (C) 2002-2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _CAPTIVE_CLIENT_FUSE_UTF8_H
+#define _CAPTIVE_CLIENT_FUSE_UTF8_H 1
+
+
+#include <captive/macros.h>
+
+
+G_BEGIN_DECLS
+
+char *capfuse_filename_to_utf8_malloc_errorchecking(const char *name);
+char *capfuse_filename_from_utf8_malloc_errorchecking(const char *name);
+
+#define CAPFUSE_FILENAME_TO_UTF8_ALLOCA(name) ({ \
+ const char *_capfuse_filename_to_utf8_alloca_name=(name); \
+ char *_capfuse_filename_to_utf8_alloca_r_malloc; \
+ const char *_capfuse_filename_to_utf8_alloca_r; \
+ \
+ _capfuse_filename_to_utf8_alloca_r_malloc=capfuse_filename_to_utf8_malloc_errorchecking( \
+ _capfuse_filename_to_utf8_alloca_name); \
+ if (!_capfuse_filename_to_utf8_alloca_r_malloc) \
+ _capfuse_filename_to_utf8_alloca_r=_capfuse_filename_to_utf8_alloca_name; \
+ else { \
+ _capfuse_filename_to_utf8_alloca_r=captive_strdup_alloca(_capfuse_filename_to_utf8_alloca_r_malloc); \
+ g_free(_capfuse_filename_to_utf8_alloca_r_malloc); \
+ } \
+ _capfuse_filename_to_utf8_alloca_r; \
+ })
+
+G_END_DECLS
+
+
+#endif /* _CAPTIVE_CLIENT_FUSE_UTF8_H */