+// Return the type of an open file
+//
+wxFileKind wxGetFileKind(int fd)
+{
+ if (isatty(fd))
+ return wxFILE_KIND_TERMINAL;
+
+#if defined __WXMSW__
+ switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
+ {
+ case FILE_TYPE_DISK:
+ return wxFILE_KIND_DISK;
+ case FILE_TYPE_PIPE:
+ return wxFILE_KIND_PIPE;
+ }
+
+ return wxFILE_KIND_UNKNOWN;
+
+#elif defined __UNIX__
+ struct stat st;
+ fstat(fd, &st);
+
+ if (S_ISFIFO(st.st_mode))
+ return wxFILE_KIND_PIPE;
+ if (!S_ISREG(st.st_mode))
+ return wxFILE_KIND_UNKNOWN;
+
+ #if defined __VMS__
+ if (st.st_fab_rfm != FAB$C_STMLF)
+ return wxFILE_KIND_UNKNOWN;
+ #endif
+
+ return wxFILE_KIND_DISK;
+
+#else
+ if (lseek(fd, 0, SEEK_CUR) != -1)
+ return wxFILE_KIND_DISK;
+ else
+ return wxFILE_KIND_UNKNOWN;
+#endif
+}