X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad0dc53bffdcc40f0b8528c30927d6ebc1fe9cbd..a6c811617b84695050e16f09b4fee518c89665a7:/src/msw/dir.cpp diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index 5fe20263aa..156147b0ae 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -6,7 +6,7 @@ // Created: 08.12.99 // RCS-ID: $Id$ // Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dir.h" #endif @@ -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" @@ -36,6 +41,10 @@ #include "wx/dir.h" #include "wx/filefn.h" // for wxPathExists() +#ifdef __WXMSW__ + #include "wx/msw/private.h" +#endif + // ---------------------------------------------------------------------------- // define the types and functions used for file searching // ---------------------------------------------------------------------------- @@ -125,8 +134,6 @@ return (attr & (_A_SYSTEM | _A_HIDDEN)) != 0; } #else // Win32 - #include - typedef WIN32_FIND_DATA FIND_STRUCT; typedef HANDLE FIND_DATA; typedef DWORD FIND_ATTR; @@ -210,6 +217,8 @@ public: void Rewind(); bool Read(wxString *filename); + const wxString& GetName() const { return m_dirname; } + private: FIND_DATA m_finddata; @@ -217,6 +226,8 @@ private: wxString m_filespec; int m_flags; + + DECLARE_NO_COPY_CLASS(wxDirData) }; // ============================================================================ @@ -398,6 +409,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; @@ -429,3 +462,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__ +