Tcl Source Code

Artifact [b4370d5060]
Login

Artifact b4370d50602ac4da9fcdea63ffe82f1dfbef2970:

Attachment "patch" to ticket [819667ffff] added by nobody 2003-10-08 07:10:02.
101c101
< static DWORD FileGetType _ANSI_ARGS_((HANDLE handle));
---
> 
755c755
<     DWORD accessMode, createMode, shareMode, flags;
---
>     DWORD accessMode, createMode, shareMode, flags, consoleParams, type;
756a757
>     DCB dcb;
854a856,875
>     type = GetFileType(handle);
> 
>     /*
>      * If the file is a character device, we need to try to figure out
>      * whether it is a serial port, a console, or something else.  We
>      * test for the console case first because this is more common.
>      */
> 
>     if (type == FILE_TYPE_CHAR) {
> 	if (GetConsoleMode(handle, &consoleParams)) {
> 	    type = FILE_TYPE_CONSOLE;
> 	} else {
> 	    dcb.DCBlength = sizeof( DCB ) ;
> 	    if (GetCommState(handle, &dcb)) {
> 		type = FILE_TYPE_SERIAL;
> 	    }
> 		    
> 	}
>     }
> 
857c878
<     switch ( FileGetType(handle) ) {
---
>     switch (type) {
939a961,962
>     DCB dcb;
>     DWORD consoleParams, type;
948c971,994
<     switch (FileGetType(handle))
---
>     /*
>      * GetFileType() returns FILE_TYPE_UNKNOWN for invalid handles.
>      */
> 
>     type = GetFileType(handle);
> 
>     /*
>      * If the file is a character device, we need to try to figure out
>      * whether it is a serial port, a console, or something else.  We
>      * test for the console case first because this is more common.
>      */
> 
>     if (type == FILE_TYPE_CHAR) {
> 	if (GetConsoleMode(handle, &consoleParams)) {
> 	    type = FILE_TYPE_CONSOLE;
> 	} else {
> 	    dcb.DCBlength = sizeof( DCB ) ;
> 	    if (GetCommState(handle, &dcb)) {
> 		type = FILE_TYPE_SERIAL;
> 	    }
> 	}
>     }
> 
>     switch (type)
1385,1431d1430
< 
< 
< /*
<  *----------------------------------------------------------------------
<  *
<  * FileGetType --
<  *
<  *	Given a file handle, return its type
<  *
<  * Results:
<  *	None.
<  *
<  * Side effects:
<  *	None.
<  *
<  *----------------------------------------------------------------------
<  */
< 
< DWORD
< FileGetType(handle)
<     HANDLE handle; /* Opened file handle */
< { 
<     DWORD type;
<     DWORD consoleParams;
<     DCB dcb;
< 
<     type = GetFileType(handle);
< 
<     /*
<      * If the file is a character device, we need to try to figure out
<      * whether it is a serial port, a console, or something else.  We
<      * test for the console case first because this is more common.
<      */
<     
<     if (type == FILE_TYPE_CHAR || (type == FILE_TYPE_UNKNOWN && !GetLastError())) {
< 	    if (GetConsoleMode(handle, &consoleParams)) {
< 	      type = FILE_TYPE_CONSOLE;
<       } else {
< 	      dcb.DCBlength = sizeof( DCB ) ;
< 	      if (GetCommState(handle, &dcb)) {
< 		      type = FILE_TYPE_SERIAL;
<         }
<       }
<     }
< 
<     return type;
< }