Warning fix for vc8, and move wxGetFileKind out of the wrong section in the
source file (was in with the globbing functions). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1843,6 +1843,79 @@ bool wxIsExecutable(const wxString &path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the type of an open file
|
||||||
|
//
|
||||||
|
// Some file types on some platforms seem seekable but in fact are not.
|
||||||
|
// The main use of this function is to allow such cases to be detected
|
||||||
|
// (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
|
||||||
|
//
|
||||||
|
// This is important for the archive streams, which benefit greatly from
|
||||||
|
// being able to seek on a stream, but which will produce corrupt archives
|
||||||
|
// if they unknowingly seek on a non-seekable stream.
|
||||||
|
//
|
||||||
|
// wxFILE_KIND_DISK is a good catch all return value, since other values
|
||||||
|
// disable features of the archive streams. Some other value must be returned
|
||||||
|
// for a file type that appears seekable but isn't.
|
||||||
|
//
|
||||||
|
// Known examples:
|
||||||
|
// * Pipes on Windows
|
||||||
|
// * Files on VMS with a record format other than StreamLF
|
||||||
|
//
|
||||||
|
wxFileKind wxGetFileKind(int fd)
|
||||||
|
{
|
||||||
|
#if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
|
||||||
|
switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
|
||||||
|
{
|
||||||
|
case FILE_TYPE_CHAR:
|
||||||
|
return wxFILE_KIND_TERMINAL;
|
||||||
|
case FILE_TYPE_DISK:
|
||||||
|
return wxFILE_KIND_DISK;
|
||||||
|
case FILE_TYPE_PIPE:
|
||||||
|
return wxFILE_KIND_PIPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxFILE_KIND_UNKNOWN;
|
||||||
|
|
||||||
|
#elif defined(__UNIX__)
|
||||||
|
if (isatty(fd))
|
||||||
|
return wxFILE_KIND_TERMINAL;
|
||||||
|
|
||||||
|
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
|
||||||
|
#define wxFILEKIND_STUB
|
||||||
|
(void)fd;
|
||||||
|
return wxFILE_KIND_DISK;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileKind wxGetFileKind(FILE *fp)
|
||||||
|
{
|
||||||
|
// Note: The watcom rtl dll doesn't have fileno (the static lib does).
|
||||||
|
// Should be fixed in version 1.4.
|
||||||
|
#if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4)
|
||||||
|
(void)fp;
|
||||||
|
return wxFILE_KIND_DISK;
|
||||||
|
#elif defined __WINDOWS__ && !defined __CYGWIN__
|
||||||
|
return fp ? wxGetFileKind(_fileno(fp)) : wxFILE_KIND_UNKNOWN;
|
||||||
|
#else
|
||||||
|
return fp ? wxGetFileKind(fileno(fp)) : wxFILE_KIND_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// wild character routines
|
// wild character routines
|
||||||
@@ -1975,77 +2048,6 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the type of an open file
|
|
||||||
//
|
|
||||||
// Some file types on some platforms seem seekable but in fact are not.
|
|
||||||
// The main use of this function is to allow such cases to be detected
|
|
||||||
// (IsSeekable() is implemented as wxGetFileKind() == wxFILE_KIND_DISK).
|
|
||||||
//
|
|
||||||
// This is important for the archive streams, which benefit greatly from
|
|
||||||
// being able to seek on a stream, but which will produce corrupt archives
|
|
||||||
// if they unknowingly seek on a non-seekable stream.
|
|
||||||
//
|
|
||||||
// wxFILE_KIND_DISK is a good catch all return value, since other values
|
|
||||||
// disable features of the archive streams. Some other value must be returned
|
|
||||||
// for a file type that appears seekable but isn't.
|
|
||||||
//
|
|
||||||
// Known examples:
|
|
||||||
// * Pipes on Windows
|
|
||||||
// * Files on VMS with a record format other than StreamLF
|
|
||||||
//
|
|
||||||
wxFileKind wxGetFileKind(int fd)
|
|
||||||
{
|
|
||||||
#if defined __WXMSW__ && !defined __WXWINCE__ && defined wxGetOSFHandle
|
|
||||||
switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
|
|
||||||
{
|
|
||||||
case FILE_TYPE_CHAR:
|
|
||||||
return wxFILE_KIND_TERMINAL;
|
|
||||||
case FILE_TYPE_DISK:
|
|
||||||
return wxFILE_KIND_DISK;
|
|
||||||
case FILE_TYPE_PIPE:
|
|
||||||
return wxFILE_KIND_PIPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxFILE_KIND_UNKNOWN;
|
|
||||||
|
|
||||||
#elif defined(__UNIX__)
|
|
||||||
if (isatty(fd))
|
|
||||||
return wxFILE_KIND_TERMINAL;
|
|
||||||
|
|
||||||
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
|
|
||||||
#define wxFILEKIND_STUB
|
|
||||||
(void)fd;
|
|
||||||
return wxFILE_KIND_DISK;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFileKind wxGetFileKind(FILE *fp)
|
|
||||||
{
|
|
||||||
// Note: The watcom rtl dll doesn't have fileno (the static lib does).
|
|
||||||
// Should be fixed in version 1.4.
|
|
||||||
#if defined(wxFILEKIND_STUB) || wxONLY_WATCOM_EARLIER_THAN(1,4)
|
|
||||||
(void)fp;
|
|
||||||
return wxFILE_KIND_DISK;
|
|
||||||
#else
|
|
||||||
return fp ? wxGetFileKind(fileno(fp)) : wxFILE_KIND_UNKNOWN;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
#pragma warning(default:4706) // assignment within conditional expression
|
#pragma warning(default:4706) // assignment within conditional expression
|
||||||
#endif // VC++
|
#endif // VC++
|
||||||
|
Reference in New Issue
Block a user