X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c5a1681bfec8912fae00c399f49492d80b946c37..83911a5a4d3be63141419b4401259093514794a3:/src/msw/dir.cpp diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index 2304b540e5..273734724d 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -28,6 +28,11 @@ #pragma hdrstop #endif +// For _A_SUBDIR, etc. +#if defined(__BORLANDC__) && defined(__WIN16__) +#include +#endif + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" @@ -210,6 +215,8 @@ public: void Rewind(); bool Read(wxString *filename); + const wxString& GetName() const { return m_dirname; } + private: FIND_DATA m_finddata; @@ -217,6 +224,8 @@ private: wxString m_filespec; int m_flags; + + DECLARE_NO_COPY_CLASS(wxDirData) }; // ============================================================================ @@ -267,9 +276,12 @@ bool wxDirData::Read(wxString *filename) if ( !IsFindDataOk(m_finddata) ) { // open first - wxString filespec; - filespec << m_dirname << _T('\\') - << (!m_filespec ? _T("*.*") : m_filespec.c_str()); + wxString filespec = m_dirname; + if ( !wxEndsWithPathSeparator(filespec) ) + { + filespec += _T('\\'); + } + filespec += (!m_filespec ? _T("*.*") : m_filespec.c_str()); m_finddata = FindFirst(filespec, PTR_TO_FINDDATA); @@ -395,6 +407,28 @@ bool wxDir::IsOpened() const return m_data != NULL; } +wxString wxDir::GetName() const +{ + wxString name; + if ( m_data ) + { + name = M_DIR->GetName(); + if ( !name.empty() ) + { + // bring to canonical Windows form + name.Replace(_T("/"), _T("\\")); + + if ( name.Last() == _T('\\') ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } + } + } + + return name; +} + wxDir::~wxDir() { delete M_DIR; @@ -426,3 +460,36 @@ bool wxDir::GetNext(wxString *filename) const return M_DIR->Read(filename); } + +// ---------------------------------------------------------------------------- +// wxGetDirectoryTimes: used by wxFileName::GetTimes() +// ---------------------------------------------------------------------------- + +#ifdef __WIN32__ + +extern bool +wxGetDirectoryTimes(const wxString& dirname, + FILETIME *ftAccess, FILETIME *ftCreate, FILETIME *ftMod) +{ + // FindFirst() is going to fail + wxASSERT_MSG( !dirname.empty() && dirname.Last() != _T('\\'), + _T("incorrect directory name format in wxGetDirectoryTimes") ); + + FIND_STRUCT fs; + FIND_DATA fd = FindFirst(dirname, &fs); + if ( !IsFindDataOk(fd) ) + { + return FALSE; + } + + *ftAccess = fs.ftLastAccessTime; + *ftCreate = fs.ftCreationTime; + *ftMod = fs.ftLastWriteTime; + + FindClose(fd); + + return TRUE; +} + +#endif // __WIN32__ +