Implemented sub-second W32 filesystem interface by new: CaptiveFileInfoObject
[captive.git] / src / client / fuse / op_utime.c
index 99f74fb..22b9386 100644 (file)
 #include <sys/stat.h>
 #include <captive/macros.h>
 #include <time.h>
+#include <captive/client-file-info.h>
 
 #include "op_utime.h"  /* self */
 #include "main.h"
 #include "gnomevfsresult.h"
-#include "gnomevfsfileinfo.h"
+#include "capfuse_captive_file_info_object.h"
 
 
 int op_utime(const char *path,struct utimbuf *buf)
 {
 CaptiveFileObject *captive_file_object;
 GnomeVFSResult errvfsresult;
-GnomeVFSFileInfo file_info;
+CaptiveFileInfoObject *captive_file_info_object;
 
        g_return_val_if_fail(path!=NULL,-EINVAL);
        g_return_val_if_fail(buf!=NULL,-EINVAL);
@@ -48,22 +49,30 @@ GnomeVFSFileInfo file_info;
                        GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_RANDOM)))
                return -gnomevfsresult_to_errno(errvfsresult);
 
-       file_info.valid_fields=0
+       if (GNOME_VFS_OK!=(errvfsresult=captive_file_info_object_new(&captive_file_info_object))) {
+               g_object_unref(captive_file_object);
+               return -gnomevfsresult_to_errno(errvfsresult);
+               }
+
+       captive_file_info_object->p.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);
+       captive_file_info_object->p.atime=buf->actime;
+       captive_file_info_object->atime_nsec=0;
+       captive_file_info_object->p.mtime=buf->modtime;
+       captive_file_info_object->mtime_nsec=0;
+       capfuse_timespec_split_get(&captive_file_info_object->p.ctime,&captive_file_info_object->ctime_nsec);
        /* 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;
+        *         captive_file_info_object->p.ctime=0; * Just sanity for sure. *
+        *         captive_file_info_object->p.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);
+       errvfsresult=captive_file_file_info_set(captive_file_object,captive_file_info_object,GNOME_VFS_SET_FILE_INFO_TIME);
 
+       g_object_unref(captive_file_info_object);
        g_object_unref(captive_file_object);
        if (GNOME_VFS_OK!=errvfsresult)
                return -gnomevfsresult_to_errno(errvfsresult);