/* $Id$ * Client fuse interface operation "utime" 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_utime.h" /* self */ #include "main.h" #include "gnomevfsresult.h" #include "gnomevfsfileinfo.h" int op_utime(const char *path,struct utimbuf *buf) { CaptiveFileObject *captive_file_object; GnomeVFSResult errvfsresult; GnomeVFSFileInfo file_info; g_return_val_if_fail(path!=NULL,-EINVAL); g_return_val_if_fail(buf!=NULL,-EINVAL); g_return_val_if_fail(buf->actime!=0,-EINVAL); g_return_val_if_fail(buf->modtime!=0,-EINVAL); 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); file_info.valid_fields=0 |GNOME_VFS_FILE_INFO_FIELDS_ATIME |GNOME_VFS_FILE_INFO_FIELDS_MTIME |GNOME_VFS_FILE_INFO_FIELDS_CTIME; file_info.atime=buf->actime; file_info.mtime=buf->modtime; file_info.ctime=time(NULL); /* Do not: * It is probably not GnomeVFS compliant but still libcaptive compatible. * * GnomeVFS looks as assuming all the three fields set. * * GnomeVFS also does not check 'valid_fields' at all. * file_info.ctime=0; * Just sanity for sure. * * file_info.valid_fields&=~GNOME_VFS_FILE_INFO_FIELDS_CTIME; * as utime() syscall should really update 'ctime' to the current time. */ errvfsresult=captive_file_file_info_set(captive_file_object,&file_info,GNOME_VFS_SET_FILE_INFO_TIME); g_object_unref(captive_file_object); if (GNOME_VFS_OK!=errvfsresult) return -gnomevfsresult_to_errno(errvfsresult); return 0; }