+ Close ();
+}
+
+void wxDirData::Close()
+{
+ if ( m_dir )
+ {
+ if ( svfs_dir_endfind (m_dir) != 0 )
+ {
+ wxLogLastError(wxT("svfs_dir_endfind"));
+ }
+ m_dir = NULL;
+ }
+}
+
+bool wxDirData::Read(wxString *filename)
+{
+ //dirent *de = NULL; // just to silence compiler warnings
+ int ret;
+ char tmpbuf[300];
+ bool matches = false;
+ size_t flags_search;
+
+ // speed up string concatenation in the loop a bit
+ wxString path = m_dirname;
+ path += wxT('/');
+ path.reserve(path.length() + 255);
+
+ wxString de_d_name;
+ de_d_name.reserve(500);
+ flags_search = 0;
+ if (wxDIR_DIRS & m_flags) {
+ flags_search |= SDIR_DIRS;
+ }
+ if (wxDIR_FILES & m_flags) {
+ flags_search |= SDIR_FILES;
+ }
+ if (NULL == m_dir) {
+#ifdef _PACC_VER
+// walk around the PalmOS pacc compiler bug
+ ret = svfs_dir_findfirst (m_dirname.fn_str().data(), &m_dir, tmpbuf, sizeof (tmpbuf), flags_search);
+#else
+ ret = svfs_dir_findfirst (m_dirname.fn_str(), &m_dir, tmpbuf, sizeof (tmpbuf), flags_search);
+#endif
+ } else {
+ ret = svfs_dir_findnext (m_dir, tmpbuf, sizeof (tmpbuf));
+ }
+ for (; ret > 0; ) {
+
+#if wxUSE_UNICODE
+ de_d_name = wxString(tmpbuf, *wxConvFileName);
+#else
+ de_d_name = tmpbuf;
+#endif
+
+ // don't return "." and ".." unless asked for
+ if ( tmpbuf[0] == '.' &&
+ ((tmpbuf[1] == '.' && tmpbuf[2] == '\0') ||
+ (tmpbuf[1] == '\0')) )
+ {
+ if ( !(m_flags & wxDIR_DOTDOT) )
+ continue;
+
+ // we found a valid match
+ break;
+ }
+
+ // check the name
+ if ( m_filespec.empty() )
+ {
+ matches = m_flags & wxDIR_HIDDEN ? true : tmpbuf[0] != '.';
+ }
+ else
+ {
+ // test against the pattern
+ matches = wxMatchWild(m_filespec, de_d_name,
+ !(m_flags & wxDIR_HIDDEN));
+ }
+ if (matches)
+ break;
+ ret = svfs_dir_findnext (m_dir, tmpbuf, sizeof (tmpbuf));
+ }
+
+ *filename = de_d_name;
+
+ return true;