// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
- #pragma implementation "dir.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#endif // PCH
#include "wx/dir.h"
-#include "wx/filefn.h" // for wxPathExists()
+#include "wx/filefn.h" // for wxDirExists()
#ifndef __DARWIN__
#include <windows.h>
void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
void SetFlags(int flags) { m_flags = flags; }
- bool Read(wxString *filename); // reads the next
+ bool Read(wxString *filename); // reads the next
void Rewind() ;
const wxString& GetName() const { return m_dirname; }
: m_dirname(dirname)
{
m_ok = false;
-
+
OSErr err;
-
+
// throw away the trailing slashes
size_t n = m_dirname.length();
wxCHECK_RET( n, _T("empty dir name in wxDir") );
;
m_dirname.Truncate(n + 1);
-
+
#ifdef __DARWIN__
FSRef theRef;
// get the FSRef associated with the POSIX path
err = FSPathMakeRef((const UInt8 *) m_dirname.c_str(), &theRef, NULL);
FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
-
+
err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
#else
FSSpec fsspec ;
{
}
-void wxDirData::Rewind()
+void wxDirData::Rewind()
{
m_index = 0 ;
}
bool wxDirData::Read(wxString *filename)
{
if ( !m_isDir )
- return FALSE ;
-
+ return false ;
+
wxString result;
short err = noErr ;
-
+
while ( err == noErr )
{
m_index++ ;
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
if ( err != noErr )
break ;
-
+
// its hidden but we don't want it
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
continue ;
// we have a directory
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
break ;
-
+
// its a file but we don't want it
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
continue ;
-
+
wxString file = wxMacMakeStringFromPascal( m_name ) ;
- if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
+ if ( m_filespec.empty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
{
}
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") )
{
continue ;
}
-
+
break ;
}
if ( err != noErr )
{
- return FALSE ;
+ return false ;
}
-
+
*filename = wxMacMakeStringFromPascal( m_name ) ;
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
- return wxPathExists(dir);
+ return wxDirExists(dir);
}
// ----------------------------------------------------------------------------
delete M_DIR;
m_data = new wxDirData(dirname);
if (m_data->Ok())
- return TRUE;
+ return true;
else
{
delete m_data;
m_data = NULL;
- return FALSE;
+ return false;
}
}
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();
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);
}