/////////////////////////////////////////////////////////////////////////////
-// Name: msw/dir.cpp
+// Name: src/msw/dir.cpp
// Purpose: wxDir implementation for Win32
// Author: Vadim Zeitlin
// Modified by:
#endif // PCH
#include "wx/dir.h"
-#include "wx/filefn.h" // for wxDirExists()
#ifdef __WINDOWS__
#include "wx/msw/private.h"
{
if ( !::FindClose(fd) )
{
- wxLogLastError(_T("FindClose"));
+ wxLogLastError(wxT("FindClose"));
}
}
inline FIND_DATA FindFirst(const wxString& spec,
FIND_STRUCT *finddata)
{
- return ::FindFirstFile(spec.fn_str(), finddata);
+ return ::FindFirstFile(spec.t_str(), finddata);
}
inline bool FindNext(FIND_DATA fd, FIND_STRUCT *finddata)
wxString filespec = m_dirname;
if ( !wxEndsWithPathSeparator(filespec) )
{
- filespec += _T('\\');
+ filespec += wxT('\\');
}
if ( !m_filespec )
- filespec += _T("*.*");
+ filespec += wxT("*.*");
else
filespec += m_filespec;
if ( err != ERROR_FILE_NOT_FOUND && err != ERROR_NO_MORE_FILES )
{
- wxLogSysError(err, _("Can not enumerate files in directory '%s'"),
+ wxLogSysError(err, _("Cannot enumerate files in directory '%s'"),
m_dirname.c_str());
}
#endif // __WIN32__
if ( err != ERROR_NO_MORE_FILES )
{
- wxLogLastError(_T("FindNext"));
+ wxLogLastError(wxT("FindNext"));
}
#endif // __WIN32__
//else: not an error, just no more (such) files
attr = GetAttrFromFindData(PTR_TO_FINDDATA);
// don't return "." and ".." unless asked for
- if ( name[0] == _T('.') &&
- ((name[1] == _T('.') && name[2] == _T('\0')) ||
- (name[1] == _T('\0'))) )
+ if ( name[0] == wxT('.') &&
+ ((name[1] == wxT('.') && name[2] == wxT('\0')) ||
+ (name[1] == wxT('\0'))) )
{
if ( !(m_flags & wxDIR_DOTDOT) )
continue;
return true;
}
-// ----------------------------------------------------------------------------
-// wxDir helpers
-// ----------------------------------------------------------------------------
-
-/* static */
-bool wxDir::Exists(const wxString& dir)
-{
- return wxDirExists(dir);
-}
-
// ----------------------------------------------------------------------------
// wxDir construction/destruction
// ----------------------------------------------------------------------------
bool wxDir::Open(const wxString& dirname)
{
delete M_DIR;
-
+
// The Unix code does a similar test
if (wxDirExists(dirname))
{
else
{
m_data = NULL;
-
+
return false;
}
}
if ( !name.empty() )
{
// bring to canonical Windows form
- name.Replace(_T("/"), _T("\\"));
+ name.Replace(wxT("/"), wxT("\\"));
- if ( name.Last() == _T('\\') )
+ if ( name.Last() == wxT('\\') )
{
// chop off the last (back)slash
name.Truncate(name.length() - 1);
return name;
}
-wxDir::~wxDir()
+void wxDir::Close()
{
- delete M_DIR;
+ if ( m_data )
+ {
+ delete m_data;
+ m_data = NULL;
+ }
}
// ----------------------------------------------------------------------------
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);
}
#ifdef __WXWINCE__
// FindFirst() is going to fail
wxASSERT_MSG( !dirname.empty(),
- _T("incorrect directory name format in wxGetDirectoryTimes") );
+ wxT("incorrect directory name format in wxGetDirectoryTimes") );
#else
// FindFirst() is going to fail
- wxASSERT_MSG( !dirname.empty() && dirname.Last() != _T('\\'),
- _T("incorrect directory name format in wxGetDirectoryTimes") );
+ wxASSERT_MSG( !dirname.empty() && dirname.Last() != wxT('\\'),
+ wxT("incorrect directory name format in wxGetDirectoryTimes") );
#endif
FIND_STRUCT fs;