/////////////////////////////////////////////////////////////////////////////
-// Name: mgl/dir.cpp
+// Name: src/mgl/dir.cpp
// Purpose: wxDir implementation for MGL
// Author: Vaclav Slavik, Vadim Zeitlin
// Modified by:
// Created: 2001/12/09
// RCS-ID: $Id$
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
-// Licence: wxWindows license
+// (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#ifdef __GNUG__
- #pragma implementation "dir.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
-#include "wx/defs.h"
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
#ifndef __UNIX__
bool IsOk() const { return m_dir != NULL; }
- void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
+ void SetFileSpec(const wxString& filespec);
void SetFlags(int flags) { m_flags = flags; }
void Rewind();
// throw away the trailing slashes
size_t n = m_dirname.length();
- wxCHECK_RET( n, _T("empty dir name in wxDir") );
+ wxCHECK_RET( n, wxT("empty dir name in wxDir") );
while ( n > 0 && m_dirname[--n] == wxFILE_SEP_PATH ) {}
PM_findClose(m_dir);
}
+void wxDirData::SetFileSpec(const wxString& filespec)
+{
+#ifdef __DOS__
+ if ( filespec.empty() )
+ m_filespec = wxT("*.*");
+ else
+#endif
+ m_filespec = filespec;
+}
+
void wxDirData::Rewind()
{
if ( m_dir )
bool wxDirData::Read(wxString *filename)
{
PM_findData data;
- bool matches = FALSE;
+ bool matches = false;
data.dwSize = sizeof(data);
-
+
wxString path = m_dirname;
path += wxFILE_SEP_PATH;
path.reserve(path.length() + 255); // speed up string concatenation
if ( m_dir )
{
if ( !PM_findNextFile(m_dir, &data) )
- return FALSE;
+ return false;
}
else
{
if ( m_dir == PM_FILE_INVALID )
{
m_dir = NULL;
- return FALSE;
+ return false;
}
}
continue;
}
- matches = m_flags & wxDIR_HIDDEN ? TRUE : !(data.attrib & PM_FILE_HIDDEN);
+ matches = m_flags & wxDIR_HIDDEN ? true : !(data.attrib & PM_FILE_HIDDEN);
}
*filename = data.name;
- return TRUE;
+ return true;
}
/* static */
bool wxDir::Exists(const wxString& dir)
{
- return wxPathExists(dir);
+ return wxDirExists(dir);
}
// ----------------------------------------------------------------------------
{
delete M_DIR;
m_data = NULL;
-
+
if ( !wxDir::Exists(dirname) )
{
wxLogError(_("Directory '%s' doesn't exist!"), dirname.c_str());
- return FALSE;
+ return false;
}
-
+
m_data = new wxDirData(dirname);
- return TRUE;
+ return true;
}
bool wxDir::IsOpened() const
const wxString& filespec,
int flags) const
{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+ wxCHECK_MSG( IsOpened(), false, wxT("must wxDir::Open() first") );
M_DIR->Rewind();
bool wxDir::GetNext(wxString *filename) const
{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+ wxCHECK_MSG( IsOpened(), false, wxT("must wxDir::Open() first") );
- wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
+ wxCHECK_MSG( filename, false, wxT("bad pointer in wxDir::GetNext()") );
return M_DIR->Read(filename);
}
#endif // !__UNIX__
-