Remove identic implementations of wxDir::Exists from platform-specific files and put it in dircmn.cpp (they all used wxDirExists).

Add wxDir::Make() and wxDir::Remove() for coherency with wxDir::Exists() and document them as simple aliases to wxFileName functions, just a bit more readable.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi 2010-06-19 11:07:16 +00:00
parent 8561534085
commit d38315df30
11 changed files with 56 additions and 81 deletions

View File

@ -83,8 +83,6 @@ class WXDLLIMPEXP_FWD_BASE wxDirData;
class WXDLLIMPEXP_BASE wxDir class WXDLLIMPEXP_BASE wxDir
{ {
public: public:
// test for existence of a directory with the given name
static bool Exists(const wxString& dir);
// ctors // ctors
// ----- // -----
@ -107,6 +105,7 @@ public:
// get the full name of the directory (without '/' at the end) // get the full name of the directory (without '/' at the end)
wxString GetName() const; wxString GetName() const;
// file enumeration routines // file enumeration routines
// ------------------------- // -------------------------
@ -151,6 +150,20 @@ public:
static wxULongLong GetTotalSize(const wxString &dir, wxArrayString *filesSkipped = NULL); static wxULongLong GetTotalSize(const wxString &dir, wxArrayString *filesSkipped = NULL);
#endif // wxUSE_LONGLONG #endif // wxUSE_LONGLONG
// static utilities for directory management
// (alias to wxFileName's functions for dirs)
// -----------------------------------------
// test for existence of a directory with the given name
static bool Exists(const wxString& dir);
static bool Make(const wxString &dir, int perm = wxS_DIR_DEFAULT,
int flags = 0);
static bool Remove(const wxString &dir, int flags = 0);
private: private:
friend class wxDirData; friend class wxDirData;

View File

@ -266,12 +266,29 @@ public:
*/ */
bool IsOpened() const; bool IsOpened() const;
/**
Creates a directory.
This is just an alias for wxFileName::Mkdir(); refer to that function
for more info.
*/
static bool Make(const wxString &dir, int perm = wxS_DIR_DEFAULT,
int flags = 0);
/** /**
Open the directory for enumerating, returns @true on success or @false Open the directory for enumerating, returns @true on success or @false
if an error occurred. if an error occurred.
*/ */
bool Open(const wxString& dir); bool Open(const wxString& dir);
/**
Removes a directory.
This is just an alias for wxFileName::Rmdir(); refer to that function
for more info.
*/
static bool Remove(const wxString &dir, int flags = 0);
/** /**
Enumerate all files and directories under the given directory Enumerate all files and directories under the given directory
recursively calling the element of the provided wxDirTraverser object recursively calling the element of the provided wxDirTraverser object

View File

@ -456,7 +456,7 @@ public:
bool DirExists() const; bool DirExists() const;
/** /**
Returns @true if the directory with this name exists. Returns @true if the directory with name @a dir exists.
*/ */
static bool DirExists(const wxString& dir); static bool DirExists(const wxString& dir);
@ -475,7 +475,7 @@ public:
bool FileExists() const; bool FileExists() const;
/** /**
Returns @true if the file with this name exists. Returns @true if the file with name @a file exists.
@see DirExists() @see DirExists()
*/ */

View File

@ -356,4 +356,26 @@ wxULongLong wxDir::GetTotalSize(const wxString &dirname, wxArrayString *filesSki
return traverser.GetTotalSize(); return traverser.GetTotalSize();
} }
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxFileName::DirExists(dir);
}
/* static */
bool wxDir::Make(const wxString &dir, int perm, int flags)
{
return wxFileName::Mkdir(dir, perm, flags);
}
/* static */
bool wxDir::Remove(const wxString &dir, int flags)
{
return wxFileName::Rmdir(dir, flags);
}
#endif // wxUSE_LONGLONG #endif // wxUSE_LONGLONG

View File

@ -179,17 +179,6 @@ bool wxDirData::Read(wxString *filename)
return true; return true;
} }
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxDirExists(dir);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -30,7 +30,6 @@
#endif // PCH #endif // PCH
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/filefn.h" // for wxDirExists()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// define the types and functions used for file searching // define the types and functions used for file searching
@ -58,16 +57,6 @@
// implementation // implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& WXUNUSED(dir))
{
return false;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -30,7 +30,6 @@
#endif // PCH #endif // PCH
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/filefn.h" // for wxDirExists()
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include "wx/msw/private.h" #include "wx/msw/private.h"
@ -287,16 +286,6 @@ bool wxDirData::Read(wxString *filename)
return true; return true;
} }
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxDirExists(dir);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -308,18 +308,6 @@ bool wxDirData::Read(
return true; return true;
} // end of wxDirData::Read } // end of wxDirData::Read
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(
const wxString& rsDir
)
{
return wxDirExists(rsDir);
} // end of wxDir::Exists
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -31,7 +31,6 @@
#include "wx/log.h" #include "wx/log.h"
#endif // PCH #endif // PCH
#include "wx/filefn.h" // for wxDirExists()
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/osx/private.h" #include "wx/osx/private.h"
@ -185,16 +184,6 @@ bool wxDirData::Read(wxString *filename)
return true; return true;
} }
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxDirExists(dir);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -30,7 +30,6 @@
#endif // PCH #endif // PCH
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/filefn.h" // for wxDirExists()
#include "pfall.h" #include "pfall.h"
@ -198,16 +197,6 @@ bool wxDirData::Read(wxString *filename)
return true; return true;
} }
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxDirExists(dir);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -197,16 +197,6 @@ bool wxDirData::Read(wxString * WXUNUSED(filename))
#endif // not or new VMS/old VMS #endif // not or new VMS/old VMS
// ----------------------------------------------------------------------------
// wxDir helpers
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
return wxDirExists(dir);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDir construction/destruction // wxDir construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------