]> git.saurik.com Git - wxWidgets.git/commitdiff
Rename wxGetFileType to wxGetFileKind
authorMichael Wetherell <mike.wetherell@ntlworld.com>
Sat, 12 Feb 2005 21:53:51 +0000 (21:53 +0000)
committerMichael Wetherell <mike.wetherell@ntlworld.com>
Sat, 12 Feb 2005 21:53:51 +0000 (21:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31974 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

17 files changed:
docs/latex/wx/ffile.tex
docs/latex/wx/file.tex
docs/latex/wx/function.tex
include/wx/ffile.h
include/wx/file.h
include/wx/filefn.h
include/wx/wfstream.h
src/common/filefn.cpp
tests/Makefile.in
tests/filekind/filekind.cpp [new file with mode: 0644]
tests/filetype/filetype.cpp [deleted file]
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/test.bkl
tests/test_test.dsp

index 5dd496b9be40b66f4938ae6559a1d70924e8fb46..3db99c9ffd6ceba75c6d37045b1a606a0a896521 100644 (file)
@@ -145,19 +145,19 @@ if the file is not opened.
 Flushes the file and returns \true on success.
 
 
-\membersection{wxFFile::GetFileType}\label{wxffilegetfiletype}
+\membersection{wxFFile::GetKind}\label{wxffilegetfilekind}
 
-\constfunc{wxFileTypeEnum}{GetFileType}{\void}
+\constfunc{wxFileKind}{GetKind}{\void}
 
 Returns the type of the file. Possible return values are:
 
 \begin{verbatim}
-enum wxFileTypeEnum
+enum wxFileKind
 {
-  wxFILE_TYPE_UNKNOWN,
-  wxFILE_TYPE_DISK,     // a file supporting seeking to arbitrary offsets
-  wxFILE_TYPE_TERMINAL, // a tty
-  wxFILE_TYPE_PIPE      // a pipe
+  wxFILE_KIND_UNKNOWN,
+  wxFILE_KIND_DISK,     // a file supporting seeking to arbitrary offsets
+  wxFILE_KIND_TERMINAL, // a tty
+  wxFILE_KIND_PIPE      // a pipe
 };
 
 \end{verbatim}
index f9bb2c69033bbf37188e695769e3eb4172b4ff21..78b5515dfc52a9d2af3121700ff20b57b61c2173 100644 (file)
@@ -200,19 +200,19 @@ Note that wxFile::Flush is not implemented on some Windows compilers
 due to a missing fsync function, which reduces the usefulness of this function
 (it can still be called but it will do nothing on unsupported compilers).
 
-\membersection{wxFile::GetFileType}\label{wxfilegetfiletype}
+\membersection{wxFile::GetKind}\label{wxfilegetfilekind}
 
-\constfunc{wxFileTypeEnum}{GetFileType}{\void}
+\constfunc{wxFileKind}{GetKind}{\void}
 
 Returns the type of the file. Possible return values are:
 
 \begin{verbatim}
-enum wxFileTypeEnum
+enum wxFileKind
 {
-  wxFILE_TYPE_UNKNOWN,
-  wxFILE_TYPE_DISK,     // a file supporting seeking to arbitrary offsets
-  wxFILE_TYPE_TERMINAL, // a tty
-  wxFILE_TYPE_PIPE      // a pipe
+  wxFILE_KIND_UNKNOWN,
+  wxFILE_KIND_DISK,     // a file supporting seeking to arbitrary offsets
+  wxFILE_KIND_TERMINAL, // a tty
+  wxFILE_KIND_PIPE      // a pipe
 };
 
 \end{verbatim}
index ad28eda84b015bf7ff6a5a33de081c068b0ea120..c6808d5e6536e2aa9dda74fde7d6d8d127e709ca 100644 (file)
@@ -108,7 +108,7 @@ the corresponding topic.
 \helpref{wxGetElapsedTime}{wxgetelapsedtime}\\
 \helpref{wxGetEmailAddress}{wxgetemailaddress}\\
 \helpref{wxGetEnv}{wxgetenv}\\
-\helpref{wxGetFileType}{wxgetfiletype}\\
+\helpref{wxGetFileKind}{wxgetfilekind}\\
 \helpref{wxGetFontFromUser}{wxgetfontfromuser}\\
 \helpref{wxGetFreeMemory}{wxgetfreememory}\\
 \helpref{wxGetFullHostName}{wxgetfullhostname}\\
@@ -1016,21 +1016,21 @@ Mac OS and generic Unix provided the system has {\tt statfs()} function.
 This function first appeared in wxWidgets 2.3.2.
 
 
-\membersection{::wxGetFileType}\label{wxgetfiletype}
+\membersection{::wxGetFileKind}\label{wxgetfilekind}
 
-\func{wxFileTypeEnum}{wxGetFileType}{\param{int }{fd}}
+\func{wxFileKind}{wxGetFileKind}{\param{int }{fd}}
 
-\func{wxFileTypeEnum}{wxGetFileType}{\param{FILE *}{fp}}
+\func{wxFileKind}{wxGetFileKind}{\param{FILE *}{fp}}
 
 Returns the type of an open file. Possible return values are:
 
 \begin{verbatim}
-enum wxFileTypeEnum
+enum wxFileKind
 {
-  wxFILE_TYPE_UNKNOWN,
-  wxFILE_TYPE_DISK,     // a file supporting seeking to arbitrary offsets
-  wxFILE_TYPE_TERMINAL, // a tty
-  wxFILE_TYPE_PIPE      // a pipe
+  wxFILE_KIND_UNKNOWN,
+  wxFILE_KIND_DISK,     // a file supporting seeking to arbitrary offsets
+  wxFILE_KIND_TERMINAL, // a tty
+  wxFILE_KIND_PIPE      // a pipe
 };
 
 \end{verbatim}
index 2e19a906ecaaab68a191e1904b12febe7522daac..f61a97fd299d003a7fccf3a39f36d784f5d5070c 100644 (file)
@@ -97,7 +97,7 @@ public:
     // get the file name
   const wxString& GetName() const { return m_name; }
     // type such as disk or pipe
-  wxFileTypeEnum GetFileType() const { return wxGetFileType(m_fp); }
+  wxFileKind GetKind() const { return wxGetFileKind(m_fp); }
 
   // dtor closes the file if opened
   ~wxFFile() { Close(); }
index 1656c175ade4b4f93e8dce3c8c9bf518f9d5467e..3382610c571f261dbf943c2b5391d91174bd9bf5 100644 (file)
@@ -126,7 +126,7 @@ public:
     // has an error occured?
   bool Error() const { return m_error; }
     // type such as disk or pipe
-  wxFileTypeEnum GetFileType() const { return wxGetFileType(m_fd); }
+  wxFileKind GetKind() const { return wxGetFileKind(m_fd); }
 
   // dtor closes the file if opened
   ~wxFile() { Close(); }
index 80cc1db89c0fc04ca7774d1d9c8305bf5e2d7657..976292adb96df14e5ded6faa2a610dc218f4dbba 100644 (file)
@@ -122,12 +122,12 @@ enum wxSeekMode
   wxFromEnd
 };
 
-enum wxFileTypeEnum
+enum wxFileKind
 {
-  wxFILE_TYPE_UNKNOWN,
-  wxFILE_TYPE_DISK,     // a file supporting seeking to arbitrary offsets
-  wxFILE_TYPE_TERMINAL, // a tty
-  wxFILE_TYPE_PIPE      // a pipe
+  wxFILE_KIND_UNKNOWN,
+  wxFILE_KIND_DISK,     // a file supporting seeking to arbitrary offsets
+  wxFILE_KIND_TERMINAL, // a tty
+  wxFILE_KIND_PIPE      // a pipe
 };
 
 // ----------------------------------------------------------------------------
@@ -464,8 +464,8 @@ WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777);
 WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0);
 
 // Return the type of an open file
-WXDLLIMPEXP_BASE wxFileTypeEnum wxGetFileType(int fd);
-inline wxFileTypeEnum wxGetFileType(FILE *fp) { return wxGetFileType(fileno(fp)); }
+WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd);
+inline wxFileKind wxGetFileKind (FILE *fp) { return wxGetFileKind(fileno(fp)); }
 
 // compatibility defines, don't use in new code
 #define wxDirExists wxPathExists
index 0b4be35d9b0b6c75e9054e5ad99fcd11ba987a40..288371487464e431b9a4eb31afd6baa4ee30d5a6 100644 (file)
@@ -41,7 +41,7 @@ public:
     wxFileOffset GetLength() const;
 
     bool Ok() const { return m_file->IsOpened(); }
-    bool IsSeekable() const { return m_file->GetFileType() == wxFILE_TYPE_DISK; }
+    bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
 
 protected:
     wxFileInputStream();
@@ -70,7 +70,7 @@ public:
     wxFileOffset GetLength() const;
 
     bool Ok() const { return m_file->IsOpened(); }
-    bool IsSeekable() const { return m_file->GetFileType() == wxFILE_TYPE_DISK; }
+    bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
 
 protected:
     wxFileOutputStream();
@@ -111,7 +111,7 @@ public:
     wxFileOffset GetLength() const;
 
     bool Ok() const { return m_file->IsOpened(); }
-    bool IsSeekable() const { return m_file->GetFileType() == wxFILE_TYPE_DISK; }
+    bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
 
 protected:
     wxFFileInputStream();
@@ -140,7 +140,7 @@ public:
     wxFileOffset GetLength() const;
 
     bool Ok() const { return m_file->IsOpened(); }
-    bool IsSeekable() const { return m_file->GetFileType() == wxFILE_TYPE_DISK; }
+    bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
 
 protected:
     wxFFileOutputStream();
index b780caad9a53fc0cfa39595a6ad601eaed3c036e..ab1e71d3457eb4340750692563ef5ec4c6e922e4 100644 (file)
@@ -1858,43 +1858,43 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
 
 // Return the type of an open file
 //
-wxFileTypeEnum wxGetFileType(int fd)
+wxFileKind wxGetFileKind(int fd)
 {
     if (isatty(fd))
-        return wxFILE_TYPE_TERMINAL;
+        return wxFILE_KIND_TERMINAL;
 
 #if defined __WXMSW__
     switch (::GetFileType(wxGetOSFHandle(fd)) & ~FILE_TYPE_REMOTE)
     {
         case FILE_TYPE_DISK:
-            return wxFILE_TYPE_DISK;
+            return wxFILE_KIND_DISK;
         case FILE_TYPE_PIPE:
-            return wxFILE_TYPE_PIPE;
+            return wxFILE_KIND_PIPE;
     }
 
-    return wxFILE_TYPE_UNKNOWN;
+    return wxFILE_KIND_UNKNOWN;
 
 #elif defined __UNIX__
     struct stat st;
     fstat(fd, &st);
 
     if (S_ISFIFO(st.st_mode))
-        return wxFILE_TYPE_PIPE;
+        return wxFILE_KIND_PIPE;
     if (!S_ISREG(st.st_mode))
-        return wxFILE_TYPE_UNKNOWN;
+        return wxFILE_KIND_UNKNOWN;
 
     #if defined __VMS__
         if (st.st_fab_rfm != FAB$C_STMLF)
-            return wxFILE_TYPE_UNKNOWN;
+            return wxFILE_KIND_UNKNOWN;
     #endif
 
-    return wxFILE_TYPE_DISK;
+    return wxFILE_KIND_DISK;
 
 #else
     if (lseek(fd, 0, SEEK_CUR) != -1)
-        return wxFILE_TYPE_DISK;
+        return wxFILE_KIND_DISK;
     else
-        return wxFILE_TYPE_UNKNOWN;
+        return wxFILE_KIND_UNKNOWN;
 #endif
 }
 
index 764a2da5c91b20c941d72a4a43bd7d4c87860b1f..039da28f09b8caaf7a986a2cad4717cc5f731984 100644 (file)
@@ -49,9 +49,9 @@ TEST_OBJECTS =  \
        test_arrays.o \
        test_datetimetest.o \
        test_fileconftest.o \
+       test_filekind.o \
        test_filenametest.o \
        test_filesystest.o \
-       test_filetype.o \
        test_fontmaptest.o \
        test_formatconvertertest.o \
        test_hashes.o \
@@ -255,15 +255,15 @@ test_datetimetest.o: $(srcdir)/datetime/datetimetest.cpp $(TEST_ODEP)
 test_fileconftest.o: $(srcdir)/fileconf/fileconftest.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/fileconf/fileconftest.cpp
 
+test_filekind.o: $(srcdir)/filekind/filekind.cpp $(TEST_ODEP)
+       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/filekind/filekind.cpp
+
 test_filenametest.o: $(srcdir)/filename/filenametest.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/filename/filenametest.cpp
 
 test_filesystest.o: $(srcdir)/filesys/filesystest.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/filesys/filesystest.cpp
 
-test_filetype.o: $(srcdir)/filetype/filetype.cpp $(TEST_ODEP)
-       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/filetype/filetype.cpp
-
 test_fontmaptest.o: $(srcdir)/fontmap/fontmaptest.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/fontmap/fontmaptest.cpp
 
diff --git a/tests/filekind/filekind.cpp b/tests/filekind/filekind.cpp
new file mode 100644 (file)
index 0000000..7cb6aa3
--- /dev/null
@@ -0,0 +1,202 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/filetype/filetype.cpp
+// Purpose:     Test wxGetFileKind and wxStreamBase::IsSeekable
+// Author:      Mike Wetherell
+// RCS-ID:      $Id$
+// Copyright:   (c) 2005 Mike Wetherell
+// Licence:     wxWidgets licence
+///////////////////////////////////////////////////////////////////////////////
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+#ifdef __UNIX__
+    #include <sys/socket.h>
+#endif
+
+#include "wx/file.h"
+#include "wx/ffile.h"
+#include "wx/wfstream.h"
+#include "wx/filename.h"
+#include "wx/socket.h"
+#include "wx/sckstrm.h"
+#include "wx/mstream.h"
+
+#if wxUSE_STREAMS
+
+///////////////////////////////////////////////////////////////////////////////
+// The test case
+
+class FileKindTestCase : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(FileKindTestCase);
+        CPPUNIT_TEST(File);
+#if defined __UNIX__ || defined _MSC_VER || defined __MINGW32__
+        CPPUNIT_TEST(Pipe);
+#endif
+#if defined __UNIX__
+        CPPUNIT_TEST(Socket);
+#endif
+        CPPUNIT_TEST(Stdin);
+        CPPUNIT_TEST(MemoryStream);
+        CPPUNIT_TEST(SocketStream);
+    CPPUNIT_TEST_SUITE_END();
+
+    void File();
+    void Pipe();
+    void Socket();
+    void Stdin();
+    void MemoryStream();
+    void SocketStream();
+
+    void TestFILE(wxFFile& file, bool expected);
+    void TestFd(wxFile& file, bool expected);
+};
+
+// test a wxFFile and wxFFileInput/OutputStreams of a known type
+// 
+void FileKindTestCase::TestFILE(wxFFile& file, bool expected)
+{
+    CPPUNIT_ASSERT(file.IsOpened());
+    CPPUNIT_ASSERT((wxGetFileKind(file.fp()) == wxFILE_KIND_DISK) == expected);
+    CPPUNIT_ASSERT((file.GetKind() == wxFILE_KIND_DISK) == expected);
+
+    wxFFileInputStream inStream(file);
+    CPPUNIT_ASSERT(inStream.IsSeekable() == expected);
+
+    wxFFileOutputStream outStream(file);
+    CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
+}
+
+// test a wxFile and wxFileInput/OutputStreams of a known type
+//
+void FileKindTestCase::TestFd(wxFile& file, bool expected)
+{
+    CPPUNIT_ASSERT(file.IsOpened());
+    CPPUNIT_ASSERT((wxGetFileKind(file.fd()) == wxFILE_KIND_DISK) == expected);
+    CPPUNIT_ASSERT((file.GetKind() == wxFILE_KIND_DISK) == expected);
+
+    wxFileInputStream inStream(file);
+    CPPUNIT_ASSERT(inStream.IsSeekable() == expected);
+
+    wxFileOutputStream outStream(file);
+    CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
+}
+
+struct TempFile
+{
+    ~TempFile() { if (!m_name.IsEmpty()) wxRemoveFile(m_name); }
+    wxString m_name;
+};
+
+// test with an ordinary file
+//
+void FileKindTestCase::File()
+{
+    TempFile tmp; // put first
+    wxFile file;
+    tmp.m_name = wxFileName::CreateTempFileName(_T("wxft"), &file);
+    TestFd(file, true);
+    file.Close();
+
+    wxFFile ffile(tmp.m_name);
+    TestFILE(ffile, true);
+}
+
+// test with a pipe
+//
+#if defined __UNIX__ || defined _MSC_VER || defined __MINGW32__
+void FileKindTestCase::Pipe()
+{
+    int afd[2];
+#ifdef __UNIX__
+    pipe(afd);
+#else
+    _pipe(afd, 256, O_BINARY);
+#endif
+
+    wxFile file0(afd[0]);
+    wxFile file1(afd[1]);
+    TestFd(file0, false);
+    file0.Detach();
+
+    wxFFile ffile(fdopen(afd[0], "r"));
+    TestFILE(ffile, false);
+}
+#endif
+
+// test with a socket
+//
+#if defined __UNIX__
+void FileKindTestCase::Socket()
+{
+    int s = socket(PF_INET, SOCK_STREAM, 0);
+
+    wxFile file(s);
+    TestFd(file, false);
+    file.Detach();
+
+    wxFFile ffile(fdopen(s, "r"));
+    TestFILE(ffile, false);
+}
+#endif
+
+// Socket streams should be non-seekable
+//
+#if wxUSE_SOCKETS
+void FileKindTestCase::SocketStream()
+{
+    wxSocketClient client;
+    wxSocketInputStream inStream(client);
+    CPPUNIT_ASSERT(!inStream.IsSeekable());
+    wxSocketOutputStream outStream(client);
+    CPPUNIT_ASSERT(!outStream.IsSeekable());
+
+    wxBufferedInputStream nonSeekableBufferedInput(inStream);
+    CPPUNIT_ASSERT(!nonSeekableBufferedInput.IsSeekable());
+    wxBufferedOutputStream nonSeekableBufferedOutput(outStream);
+    CPPUNIT_ASSERT(!nonSeekableBufferedOutput.IsSeekable());
+}
+#endif
+
+// Memory streams should be seekable
+//
+void FileKindTestCase::MemoryStream()
+{
+    char buf[20];
+    wxMemoryInputStream inStream(buf, sizeof(buf));
+    CPPUNIT_ASSERT(inStream.IsSeekable());
+    wxMemoryOutputStream outStream(buf, sizeof(buf));
+    CPPUNIT_ASSERT(outStream.IsSeekable());
+
+    wxBufferedInputStream seekableBufferedInput(inStream);
+    CPPUNIT_ASSERT(seekableBufferedInput.IsSeekable());
+    wxBufferedOutputStream seekableBufferedOutput(outStream);
+    CPPUNIT_ASSERT(seekableBufferedOutput.IsSeekable());
+}
+
+// Stdin will usually be a terminal, if so then test it
+// 
+void FileKindTestCase::Stdin()
+{
+    if (isatty(0))
+        CPPUNIT_ASSERT(wxGetFileKind(0) == wxFILE_KIND_TERMINAL);
+    if (isatty(fileno(stdin)))
+        CPPUNIT_ASSERT(wxGetFileKind(stdin) == wxFILE_KIND_TERMINAL);
+}
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION(FileKindTestCase);
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FileKindTestCase, "FileKindTestCase");
+
+#endif // wxUSE_STREAMS
diff --git a/tests/filetype/filetype.cpp b/tests/filetype/filetype.cpp
deleted file mode 100644 (file)
index 5eb8216..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Name:        tests/filetype/filetype.cpp
-// Purpose:     Test wxGetFileType and wxStreamBase::IsSeekable
-// Author:      Mike Wetherell
-// RCS-ID:      $Id$
-// Copyright:   (c) 2005 Mike Wetherell
-// Licence:     wxWidgets licence
-///////////////////////////////////////////////////////////////////////////////
-
-#include "testprec.h"
-
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
-// for all others, include the necessary headers
-#ifndef WX_PRECOMP
-    #include "wx/wx.h"
-#endif
-
-#ifdef __UNIX__
-    #include <sys/socket.h>
-#endif
-
-#include "wx/file.h"
-#include "wx/ffile.h"
-#include "wx/wfstream.h"
-#include "wx/filename.h"
-#include "wx/socket.h"
-#include "wx/sckstrm.h"
-#include "wx/mstream.h"
-
-#if wxUSE_STREAMS
-
-///////////////////////////////////////////////////////////////////////////////
-// The test case
-
-class FileTypeTestCase : public CppUnit::TestCase
-{
-    CPPUNIT_TEST_SUITE(FileTypeTestCase);
-        CPPUNIT_TEST(File);
-#if defined __UNIX__ || defined _MSC_VER || defined __MINGW32__
-        CPPUNIT_TEST(Pipe);
-#endif
-#if defined __UNIX__
-        CPPUNIT_TEST(Socket);
-#endif
-        CPPUNIT_TEST(Stdin);
-        CPPUNIT_TEST(MemoryStream);
-        CPPUNIT_TEST(SocketStream);
-    CPPUNIT_TEST_SUITE_END();
-
-    void File();
-    void Pipe();
-    void Socket();
-    void Stdin();
-    void MemoryStream();
-    void SocketStream();
-
-    void TestFILE(wxFFile& file, bool expected);
-    void TestFd(wxFile& file, bool expected);
-};
-
-// test a wxFFile and wxFFileInput/OutputStreams of a known type
-// 
-void FileTypeTestCase::TestFILE(wxFFile& file, bool expected)
-{
-    CPPUNIT_ASSERT(file.IsOpened());
-    CPPUNIT_ASSERT((wxGetFileType(file.fp()) == wxFILE_TYPE_DISK) == expected);
-    CPPUNIT_ASSERT((file.GetFileType() == wxFILE_TYPE_DISK) == expected);
-
-    wxFFileInputStream inStream(file);
-    CPPUNIT_ASSERT(inStream.IsSeekable() == expected);
-
-    wxFFileOutputStream outStream(file);
-    CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
-}
-
-// test a wxFile and wxFileInput/OutputStreams of a known type
-//
-void FileTypeTestCase::TestFd(wxFile& file, bool expected)
-{
-    CPPUNIT_ASSERT(file.IsOpened());
-    CPPUNIT_ASSERT((wxGetFileType(file.fd()) == wxFILE_TYPE_DISK) == expected);
-    CPPUNIT_ASSERT((file.GetFileType() == wxFILE_TYPE_DISK) == expected);
-
-    wxFileInputStream inStream(file);
-    CPPUNIT_ASSERT(inStream.IsSeekable() == expected);
-
-    wxFileOutputStream outStream(file);
-    CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
-}
-
-struct TempFile
-{
-    ~TempFile() { if (!m_name.IsEmpty()) wxRemoveFile(m_name); }
-    wxString m_name;
-};
-
-// test with an ordinary file
-//
-void FileTypeTestCase::File()
-{
-    TempFile tmp; // put first
-    wxFile file;
-    tmp.m_name = wxFileName::CreateTempFileName(_T("wxft"), &file);
-    TestFd(file, true);
-    file.Close();
-
-    wxFFile ffile(tmp.m_name);
-    TestFILE(ffile, true);
-}
-
-// test with a pipe
-//
-#if defined __UNIX__ || defined _MSC_VER || defined __MINGW32__
-void FileTypeTestCase::Pipe()
-{
-    int afd[2];
-#ifdef __UNIX__
-    pipe(afd);
-#else
-    _pipe(afd, 256, O_BINARY);
-#endif
-
-    wxFile file0(afd[0]);
-    wxFile file1(afd[1]);
-    TestFd(file0, false);
-    file0.Detach();
-
-    wxFFile ffile(fdopen(afd[0], "r"));
-    TestFILE(ffile, false);
-}
-#endif
-
-// test with a socket
-//
-#if defined __UNIX__
-void FileTypeTestCase::Socket()
-{
-    int s = socket(PF_INET, SOCK_STREAM, 0);
-
-    wxFile file(s);
-    TestFd(file, false);
-    file.Detach();
-
-    wxFFile ffile(fdopen(s, "r"));
-    TestFILE(ffile, false);
-}
-#endif
-
-// Socket streams should be non-seekable
-//
-#if wxUSE_SOCKETS
-void FileTypeTestCase::SocketStream()
-{
-    wxSocketClient client;
-    wxSocketInputStream inStream(client);
-    CPPUNIT_ASSERT(!inStream.IsSeekable());
-    wxSocketOutputStream outStream(client);
-    CPPUNIT_ASSERT(!outStream.IsSeekable());
-
-    wxBufferedInputStream nonSeekableBufferedInput(inStream);
-    CPPUNIT_ASSERT(!nonSeekableBufferedInput.IsSeekable());
-    wxBufferedOutputStream nonSeekableBufferedOutput(outStream);
-    CPPUNIT_ASSERT(!nonSeekableBufferedOutput.IsSeekable());
-}
-#endif
-
-// Memory streams should be seekable
-//
-void FileTypeTestCase::MemoryStream()
-{
-    char buf[20];
-    wxMemoryInputStream inStream(buf, sizeof(buf));
-    CPPUNIT_ASSERT(inStream.IsSeekable());
-    wxMemoryOutputStream outStream(buf, sizeof(buf));
-    CPPUNIT_ASSERT(outStream.IsSeekable());
-
-    wxBufferedInputStream seekableBufferedInput(inStream);
-    CPPUNIT_ASSERT(seekableBufferedInput.IsSeekable());
-    wxBufferedOutputStream seekableBufferedOutput(outStream);
-    CPPUNIT_ASSERT(seekableBufferedOutput.IsSeekable());
-}
-
-// Stdin will usually be a terminal, if so then test it
-// 
-void FileTypeTestCase::Stdin()
-{
-    if (isatty(0))
-        CPPUNIT_ASSERT(wxGetFileType(0) == wxFILE_TYPE_TERMINAL);
-    if (isatty(fileno(stdin)))
-        CPPUNIT_ASSERT(wxGetFileType(stdin) == wxFILE_TYPE_TERMINAL);
-}
-
-// register in the unnamed registry so that these tests are run by default
-CPPUNIT_TEST_SUITE_REGISTRATION(FileTypeTestCase);
-
-// also include in it's own registry so that these tests can be run alone
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FileTypeTestCase, "FileTypeTestCase");
-
-#endif // wxUSE_STREAMS
index 2f3720e4b9b8fedd5ff91206edfee3678ee4fdd6..ab60059c57b6ef59a332907abe50213322d23e69 100644 (file)
@@ -40,9 +40,9 @@ TEST_OBJECTS =  \
        $(OBJS)\test_arrays.obj \
        $(OBJS)\test_datetimetest.obj \
        $(OBJS)\test_fileconftest.obj \
+       $(OBJS)\test_filekind.obj \
        $(OBJS)\test_filenametest.obj \
        $(OBJS)\test_filesystest.obj \
-       $(OBJS)\test_filetype.obj \
        $(OBJS)\test_fontmaptest.obj \
        $(OBJS)\test_formatconvertertest.obj \
        $(OBJS)\test_hashes.obj \
@@ -267,13 +267,13 @@ $(OBJS)\test_datetimetest.obj: .\datetime\datetimetest.cpp
 $(OBJS)\test_fileconftest.obj: .\fileconf\fileconftest.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filenametest.obj: .\filename\filenametest.cpp
+$(OBJS)\test_filekind.obj: .\filekind\filekind.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filesystest.obj: .\filesys\filesystest.cpp
+$(OBJS)\test_filenametest.obj: .\filename\filenametest.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filetype.obj: .\filetype\filetype.cpp
+$(OBJS)\test_filesystest.obj: .\filesys\filesystest.cpp
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
 $(OBJS)\test_fontmaptest.obj: .\fontmap\fontmaptest.cpp
index 6ae8c2a5248f05376a17a70872d35f66c1be7772..0ade361a4aa48d43235fe904c219747723ebcc10 100644 (file)
@@ -31,9 +31,9 @@ TEST_OBJECTS =  \
        $(OBJS)\test_arrays.o \
        $(OBJS)\test_datetimetest.o \
        $(OBJS)\test_fileconftest.o \
+       $(OBJS)\test_filekind.o \
        $(OBJS)\test_filenametest.o \
        $(OBJS)\test_filesystest.o \
-       $(OBJS)\test_filetype.o \
        $(OBJS)\test_fontmaptest.o \
        $(OBJS)\test_formatconvertertest.o \
        $(OBJS)\test_hashes.o \
@@ -256,13 +256,13 @@ $(OBJS)\test_datetimetest.o: ./datetime/datetimetest.cpp
 $(OBJS)\test_fileconftest.o: ./fileconf/fileconftest.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filenametest.o: ./filename/filenametest.cpp
+$(OBJS)\test_filekind.o: ./filekind/filekind.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filesystest.o: ./filesys/filesystest.cpp
+$(OBJS)\test_filenametest.o: ./filename/filenametest.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filetype.o: ./filetype/filetype.cpp
+$(OBJS)\test_filesystest.o: ./filesys/filesystest.cpp
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
 $(OBJS)\test_fontmaptest.o: ./fontmap/fontmaptest.cpp
index 1c47dd54925bc3484c1f26f6c28783e585ce3bb3..10d9f2fda25cd8fa9662264463d0f3d19053db72 100644 (file)
@@ -33,9 +33,9 @@ TEST_OBJECTS =  \
        $(OBJS)\test_arrays.obj \
        $(OBJS)\test_datetimetest.obj \
        $(OBJS)\test_fileconftest.obj \
+       $(OBJS)\test_filekind.obj \
        $(OBJS)\test_filenametest.obj \
        $(OBJS)\test_filesystest.obj \
-       $(OBJS)\test_filetype.obj \
        $(OBJS)\test_fontmaptest.obj \
        $(OBJS)\test_formatconvertertest.obj \
        $(OBJS)\test_hashes.obj \
@@ -368,13 +368,13 @@ $(OBJS)\test_datetimetest.obj: .\datetime\datetimetest.cpp
 $(OBJS)\test_fileconftest.obj: .\fileconf\fileconftest.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filenametest.obj: .\filename\filenametest.cpp
+$(OBJS)\test_filekind.obj: .\filekind\filekind.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filesystest.obj: .\filesys\filesystest.cpp
+$(OBJS)\test_filenametest.obj: .\filename\filenametest.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
-$(OBJS)\test_filetype.obj: .\filetype\filetype.cpp
+$(OBJS)\test_filesystest.obj: .\filesys\filesystest.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
 $(OBJS)\test_fontmaptest.obj: .\fontmap\fontmaptest.cpp
index 40cd9bed32f919d27d1ac23a2c21d17d4ec65e34..2b5866d43c85b44c4bebaf80edd58969ee2f7738 100644 (file)
@@ -211,9 +211,9 @@ TEST_OBJECTS =  &
        $(OBJS)\test_arrays.obj &
        $(OBJS)\test_datetimetest.obj &
        $(OBJS)\test_fileconftest.obj &
+       $(OBJS)\test_filekind.obj &
        $(OBJS)\test_filenametest.obj &
        $(OBJS)\test_filesystest.obj &
-       $(OBJS)\test_filetype.obj &
        $(OBJS)\test_fontmaptest.obj &
        $(OBJS)\test_formatconvertertest.obj &
        $(OBJS)\test_hashes.obj &
@@ -316,13 +316,13 @@ $(OBJS)\test_datetimetest.obj :  .AUTODEPEND .\datetime\datetimetest.cpp
 $(OBJS)\test_fileconftest.obj :  .AUTODEPEND .\fileconf\fileconftest.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filenametest.obj :  .AUTODEPEND .\filename\filenametest.cpp
+$(OBJS)\test_filekind.obj :  .AUTODEPEND .\filekind\filekind.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filesystest.obj :  .AUTODEPEND .\filesys\filesystest.cpp
+$(OBJS)\test_filenametest.obj :  .AUTODEPEND .\filename\filenametest.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
-$(OBJS)\test_filetype.obj :  .AUTODEPEND .\filetype\filetype.cpp
+$(OBJS)\test_filesystest.obj :  .AUTODEPEND .\filesys\filesystest.cpp
        $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
 $(OBJS)\test_fontmaptest.obj :  .AUTODEPEND .\fontmap\fontmaptest.cpp
index 81084fec2c8ace5349c594e8b066c9598cfee2d1..16bb6666af8897a2e3c99027708390f85db4008e 100644 (file)
@@ -29,9 +29,9 @@
             arrays/arrays.cpp
             datetime/datetimetest.cpp
             fileconf/fileconftest.cpp
+            filekind/filekind.cpp
             filename/filenametest.cpp
             filesys/filesystest.cpp
-            filetype/filetype.cpp
             fontmap/fontmaptest.cpp
             formatconverter/formatconvertertest.cpp
             hashes/hashes.cpp
index f82da313ff8e0c00f9f0be85954bb3add5953ac4..8d2a6df7d8f742ade7fe86a71360bcf80965f188 100644 (file)
@@ -473,19 +473,19 @@ SOURCE=.\fileconf\fileconftest.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\filename\filenametest.cpp
+SOURCE=.\filekind\filekind.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\streams\filestream.cpp
+SOURCE=.\filename\filenametest.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\filesys\filesystest.cpp
+SOURCE=.\streams\filestream.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\filetype\filetype.cpp
+SOURCE=.\filesys\filesystest.cpp
 # End Source File
 # Begin Source File