X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..d2b23b67301bd2d286366d4326a21da3132558fa:/src/msw/dir.cpp diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index fc9c933185..bfca51b322 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dir.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -34,9 +30,9 @@ #endif // PCH #include "wx/dir.h" -#include "wx/filefn.h" // for wxPathExists() +#include "wx/filefn.h" // for wxDirExists() -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #include "wx/msw/private.h" #endif @@ -175,7 +171,7 @@ void wxDirData::Rewind() bool wxDirData::Read(wxString *filename) { - bool first = FALSE; + bool first = false; WIN32_FIND_DATA finddata; #define PTR_TO_FINDDATA (&finddata) @@ -188,11 +184,14 @@ bool wxDirData::Read(wxString *filename) { filespec += _T('\\'); } - filespec += (!m_filespec ? _T("*.*") : m_filespec.c_str()); + if ( !m_filespec ) + filespec += _T("*.*"); + else + filespec += m_filespec; m_finddata = FindFirst(filespec, PTR_TO_FINDDATA); - first = TRUE; + first = true; } if ( !IsFindDataOk(m_finddata) ) @@ -200,7 +199,7 @@ bool wxDirData::Read(wxString *filename) #ifdef __WIN32__ DWORD err = ::GetLastError(); - if ( err != ERROR_FILE_NOT_FOUND ) + if ( err != ERROR_FILE_NOT_FOUND && err != ERROR_NO_MORE_FILES ) { wxLogSysError(err, _("Can not enumerate files in directory '%s'"), m_dirname.c_str()); @@ -208,7 +207,7 @@ bool wxDirData::Read(wxString *filename) #endif // __WIN32__ //else: not an error, just no (such) files - return FALSE; + return false; } const wxChar *name; @@ -218,7 +217,7 @@ bool wxDirData::Read(wxString *filename) { if ( first ) { - first = FALSE; + first = false; } else { @@ -234,7 +233,7 @@ bool wxDirData::Read(wxString *filename) #endif // __WIN32__ //else: not an error, just no more (such) files - return FALSE; + return false; } } @@ -277,7 +276,7 @@ bool wxDirData::Read(wxString *filename) break; } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -287,7 +286,7 @@ bool wxDirData::Read(wxString *filename) /* static */ bool wxDir::Exists(const wxString& dir) { - return wxPathExists(dir); + return wxDirExists(dir); } // ---------------------------------------------------------------------------- @@ -306,7 +305,7 @@ bool wxDir::Open(const wxString& dirname) delete M_DIR; m_data = new wxDirData(dirname); - return TRUE; + return true; } bool wxDir::IsOpened() const @@ -349,7 +348,7 @@ bool wxDir::GetFirst(wxString *filename, const wxString& filespec, int flags) const { - wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") ); + wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") ); M_DIR->Rewind(); @@ -361,9 +360,9 @@ bool wxDir::GetFirst(wxString *filename, bool wxDir::GetNext(wxString *filename) const { - wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") ); + wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") ); - wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") ); + wxCHECK_MSG( filename, false, _T("bad pointer in wxDir::GetNext()") ); return M_DIR->Read(filename); } @@ -378,15 +377,21 @@ extern bool wxGetDirectoryTimes(const wxString& dirname, FILETIME *ftAccess, FILETIME *ftCreate, FILETIME *ftMod) { +#ifdef __WXWINCE__ + // FindFirst() is going to fail + wxASSERT_MSG( !dirname.empty(), + _T("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") ); +#endif FIND_STRUCT fs; FIND_DATA fd = FindFirst(dirname, &fs); if ( !IsFindDataOk(fd) ) { - return FALSE; + return false; } *ftAccess = fs.ftLastAccessTime; @@ -395,7 +400,7 @@ wxGetDirectoryTimes(const wxString& dirname, FindClose(fd); - return TRUE; + return true; } #endif // __WIN32__