X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1944c6bdd0daa0a9793e9a57f0800c169fec958b..b838cfc9151aea38402ad2b1ba5d2f97cf94e973:/src/unix/dir.cpp?ds=inline diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp index 188e93c6e5..13b8d2a68a 100644 --- a/src/unix/dir.cpp +++ b/src/unix/dir.cpp @@ -65,6 +65,8 @@ public: void Rewind() { rewinddir(m_dir); } bool Read(wxString *filename); + const wxString& GetName() const { return m_dirname; } + private: DIR *m_dir; @@ -115,7 +117,7 @@ wxDirData::~wxDirData() bool wxDirData::Read(wxString *filename) { - dirent *de; + dirent *de = (dirent *)NULL; // just to silent compiler warnings bool matches = FALSE; while ( !matches ) @@ -228,6 +230,22 @@ bool wxDir::IsOpened() const return m_data != NULL; } +wxString wxDir::GetName() const +{ + wxString name; + if ( m_data ) + { + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } + } + + return name; +} + wxDir::~wxDir() { delete M_DIR;