@@ -741,6 +741,48 @@ static int is_local_named_pipe_path(const char *filename)
741
741
filename [9 ]);
742
742
}
743
743
744
+ static int is_local_disk_file (const char * filename )
745
+ {
746
+ wchar_t wpath [MAX_LONG_PATH ];
747
+ wchar_t wfullpath [MAX_LONG_PATH ];
748
+ size_t windex ;
749
+
750
+ if (is_local_named_pipe_path (filename ))
751
+ return 0 ;
752
+
753
+ /*
754
+ * Do everything in wide chars because the drive letter might be
755
+ * a multi-byte sequence. See win32_has_dos_drive_prefix().
756
+ */
757
+ if (xutftowcs_long_path (wpath , filename ) < 0 )
758
+ return 0 ;
759
+
760
+ /*
761
+ * GetDriveTypeW() requires a final slash.
762
+ */
763
+ windex = wcslen (wpath ) - 1 ;
764
+ while (windex >= 0 ) {
765
+ if (is_dir_sep (wpath [windex ]))
766
+ break ;
767
+ windex -- ;
768
+ }
769
+ wpath [windex ++ ] = L'\\' ;
770
+ wpath [windex ] = 0 ;
771
+
772
+ /*
773
+ * Normalize the path. If nothing else, this converts forward
774
+ * slashes to backslashes. This is essential to get GetDriveTypeW()
775
+ * correctly handle some UNC "\\server\share\..." paths.
776
+ */
777
+ if (!GetFullPathNameW (wpath , MAX_LONG_PATH , wfullpath , NULL ))
778
+ return 0 ;
779
+
780
+ if (GetDriveTypeW (wfullpath ) == DRIVE_REMOTE )
781
+ return 0 ;
782
+
783
+ return 1 ;
784
+ }
785
+
744
786
int mingw_open (const char * filename , int oflags , ...)
745
787
{
746
788
typedef int (* open_fn_t )(wchar_t const * wfilename , int oflags , ...);
@@ -759,7 +801,7 @@ int mingw_open (const char *filename, int oflags, ...)
759
801
return -1 ;
760
802
}
761
803
762
- if ((oflags & O_APPEND ) && ! is_local_named_pipe_path (filename ))
804
+ if ((oflags & O_APPEND ) && is_local_disk_file (filename ))
763
805
open_fn = mingw_open_append ;
764
806
else
765
807
open_fn = _wopen ;
0 commit comments