/* $Id$ * Client fuse interface operation "open" for libcaptive * Copyright (C) 2005 Jan Kratochvil * * 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 #include #include #include #include #include #include #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) { CaptiveFileObject *captive_file_object; GnomeVFSResult errvfsresult; g_return_val_if_fail(path!=NULL,-EINVAL); g_return_val_if_fail(fi!=NULL,-EINVAL); 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) || (!(fi->flags&(O_WRONLY|O_RDWR|O_APPEND)) ? 0 : GNOME_VFS_OPEN_WRITE)))) return -gnomevfsresult_to_errno(errvfsresult); fi->fh=(unsigned long)captive_file_object; /* No data can change beneath FUSE. */ fi->keep_cache=1; return 0; }