comm patch

Andreas Mohr a.mohr at mailto.de
Fri Mar 2 22:39:33 CST 2001


Hello all,

GetFileInformationByHandle() fails for pipe handles according to
MSDN, and also for serial handles (FILE_TYPE_CHAR in general ?).
The success of this function led to GetFileSize and GetFileTime
returning incorrect values.
When corrected, the existing infrastructure of Wine already did the
right thing, except for GetFileSize, which returns -1 for failure, not 0.

This happened with the comm software for the Siemens IC35 PDA, BTW.
(thanks, Dominik Strasser ! :-)

Does IC35 work now ? (I doubt it...)

Andreas Mohr
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: files/file.c
===================================================================
RCS file: /home/wine/wine/files/file.c,v
retrieving revision 1.93
diff -u -r1.93 file.c
--- files/file.c	2001/03/01 22:13:49	1.93
+++ files/file.c	2001/03/02 22:42:59
@@ -557,16 +557,30 @@
         req->handle = hFile;
         if ((ret = !SERVER_CALL_ERR()))
         {
-            RtlSecondsSince1970ToTime( req->write_time, &info->ftCreationTime );
-            RtlSecondsSince1970ToTime( req->write_time, &info->ftLastWriteTime );
-            RtlSecondsSince1970ToTime( req->access_time, &info->ftLastAccessTime );
-            info->dwFileAttributes     = req->attr;
-            info->dwVolumeSerialNumber = req->serial;
-            info->nFileSizeHigh        = req->size_high;
-            info->nFileSizeLow         = req->size_low;
-            info->nNumberOfLinks       = req->links;
-            info->nFileIndexHigh       = req->index_high;
-            info->nFileIndexLow        = req->index_low;
+	    /* FIXME: which file types are supported ?
+	     * Serial ports (FILE_TYPE_CHAR) are not,
+	     * and MSDN also says that pipes are not supported.
+	     * FILE_TYPE_REMOTE seems to be supported according to
+	     * MSDN q234741.txt */
+	    if ((req->type == FILE_TYPE_DISK)
+	    ||  (req->type == FILE_TYPE_REMOTE))
+	    {
+                RtlSecondsSince1970ToTime( req->write_time, &info->ftCreationTime );
+                RtlSecondsSince1970ToTime( req->write_time, &info->ftLastWriteTime );
+                RtlSecondsSince1970ToTime( req->access_time, &info->ftLastAccessTime );
+                info->dwFileAttributes     = req->attr;
+                info->dwVolumeSerialNumber = req->serial;
+                info->nFileSizeHigh        = req->size_high;
+                info->nFileSizeLow         = req->size_low;
+                info->nNumberOfLinks       = req->links;
+                info->nFileIndexHigh       = req->index_high;
+                info->nFileIndexLow        = req->index_low;
+	    }
+	    else
+	    {
+		SetLastError(ERROR_NOT_SUPPORTED);
+		ret = 0;
+	    }
         }
     }
     SERVER_END_REQ;
@@ -621,7 +635,7 @@
 DWORD WINAPI GetFileSize( HANDLE hFile, LPDWORD filesizehigh )
 {
     BY_HANDLE_FILE_INFORMATION info;
-    if (!GetFileInformationByHandle( hFile, &info )) return 0;
+    if (!GetFileInformationByHandle( hFile, &info )) return -1;
     if (filesizehigh) *filesizehigh = info.nFileSizeHigh;
     return info.nFileSizeLow;
 }


More information about the wine-patches mailing list