+ wxString cwd = wxGetCwd();
+ if ( !wxDir::Exists(cwd) )
+ {
+ printf("ERROR: current directory '%s' doesn't exist?\n", cwd.c_str());
+ return;
+ }
+
+ wxDir dir("s:/tmp/foo");
+ if ( !dir.IsOpened() )
+ {
+ printf("ERROR: failed to open current directory '%s'.\n", cwd.c_str());
+ return;
+ }
+static void TestDirExists()
+{
+ wxPuts(_T("*** Testing wxDir::Exists() ***"));
+
+ static const char *dirnames[] =
+ {
+ _T("."),
+#if defined(__WXMSW__)
+ _T("c:"),
+ _T("c:\\"),
+ _T("\\\\share\\file"),
+ _T("c:\\dos"),
+ _T("c:\\dos\\"),
+ _T("c:\\dos\\\\"),
+ _T("c:\\autoexec.bat"),
+#elif defined(__UNIX__)
+ _T("/"),
+ _T("//"),
+ _T("/usr/bin"),
+ _T("/usr//bin"),
+ _T("/usr///bin"),
+#endif
+ };
+
+ for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
+ {
+ printf(_T("%-40s: %s\n"),
+ dirnames[n],
+ wxDir::Exists(dirnames[n]) ? _T("exists") : _T("doesn't exist"));
+ }
+}
+
fn.GetPath(wxPATH_GET_SEPARATOR).c_str());
wxPrintf(_T("with both: \t'%s'\n"),
fn.GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME).c_str());
fn.GetPath(wxPATH_GET_SEPARATOR).c_str());
wxPrintf(_T("with both: \t'%s'\n"),
fn.GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME).c_str());
+
+ wxPuts(_T("The directories in the path are:"));
+ wxArrayString dirs = fn.GetDirs();
+ size_t count = dirs.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxPrintf(_T("\t%u: %s\n"), n, dirs[n].c_str());
+ }
{ _T("c:\\foo.bar"), _T("c"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
{ _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), TRUE, wxPATH_DOS },
{ _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
{ _T("c:\\foo.bar"), _T("c"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
{ _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), TRUE, wxPATH_DOS },
{ _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
+ { _T("\\\\server\\dir\\foo.bar"), _T("server"), _T("\\dir"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
- puts("*** Testing wxMemoryInputStream ***");
+ wxPuts(_T("*** Testing wxMemoryOutputStream ***"));
+
+ wxMemoryOutputStream memOutStream;
+ wxPrintf(_T("Initially out stream offset: %lu\n"),
+ (unsigned long)memOutStream.TellO());
+
+ for ( const wxChar *p = _T("Hello, stream!"); *p; p++ )
+ {
+ memOutStream.PutC(*p);
+ }
+
+ wxPrintf(_T("Final out stream offset: %lu\n"),
+ (unsigned long)memOutStream.TellO());
+
+ wxPuts(_T("*** Testing wxMemoryInputStream ***"));
- wxMemoryInputStream memInpStream(buf, wxStrlen(buf));
- printf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
+ wxMemoryInputStream memInpStream(buf, len);
+ wxPrintf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
static void TestZlibStreamWrite()
{
puts("*** Testing Zlib stream reading ***\n");
wxFileOutputStream fileOutStream(FILENAME_GZ);
static void TestZlibStreamWrite()
{
puts("*** Testing Zlib stream reading ***\n");
wxFileOutputStream fileOutStream(FILENAME_GZ);
- wxPrintf(_T("%s: Thread %d starting to wait for semaphore...\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) starting to wait for semaphore...\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());
- wxPrintf(_T("%s: Thread %d acquired the semaphore.\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) acquired the semaphore.\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());
- wxPrintf(_T("%s: Thread %d releasing the semaphore.\n"),
- wxDateTime::Now().FormatTime().c_str(), m_i);
+ wxPrintf(_T("%s: Thread #%d (%ld) releasing the semaphore.\n"),
+ wxDateTime::Now().FormatTime().c_str(), m_i, (long)GetId());