Added 'full' param to wxFileName::Mkdir to make all directories in a path,
not just the last one git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -166,9 +166,10 @@ public:
|
|||||||
// get a temp file name starting with thespecified prefix
|
// get a temp file name starting with thespecified prefix
|
||||||
void AssignTempFileName( const wxString &prefix );
|
void AssignTempFileName( const wxString &prefix );
|
||||||
|
|
||||||
// directory creation and removal
|
// directory creation and removal.
|
||||||
bool Mkdir( int perm = 0777 );
|
// if full is TRUE, will try to make each directory in the path.
|
||||||
static bool Mkdir( const wxString &dir, int perm = 0777 );
|
bool Mkdir( int perm = 0777, bool full = FALSE);
|
||||||
|
static bool Mkdir( const wxString &dir, int perm = 0777, bool full = FALSE );
|
||||||
|
|
||||||
bool Rmdir();
|
bool Rmdir();
|
||||||
static bool Rmdir( const wxString &dir );
|
static bool Rmdir( const wxString &dir );
|
||||||
|
@@ -204,13 +204,45 @@ void wxFileName::AssignTempFileName( const wxString &prefix )
|
|||||||
// directory operations
|
// directory operations
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxFileName::Mkdir( int perm )
|
bool wxFileName::Mkdir( int perm, bool full )
|
||||||
{
|
{
|
||||||
return wxFileName::Mkdir( GetFullPath(), perm );
|
return wxFileName::Mkdir( GetFullPath(), perm, full );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileName::Mkdir( const wxString &dir, int perm )
|
bool wxFileName::Mkdir( const wxString &dir, int perm, bool full )
|
||||||
{
|
{
|
||||||
|
if (full)
|
||||||
|
{
|
||||||
|
wxFileName filename(dir);
|
||||||
|
wxArrayString dirs = filename.GetDirs();
|
||||||
|
|
||||||
|
size_t count = dirs.GetCount();
|
||||||
|
size_t i;
|
||||||
|
wxString currPath;
|
||||||
|
int noErrors = 0;
|
||||||
|
for ( i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
currPath += dirs[i];
|
||||||
|
|
||||||
|
if (currPath.Last() == wxT(':'))
|
||||||
|
{
|
||||||
|
// Can't create a root directory so continue to next dir
|
||||||
|
currPath += wxFILE_SEP_PATH;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DirExists(currPath))
|
||||||
|
if (!wxMkdir(currPath, perm))
|
||||||
|
noErrors ++;
|
||||||
|
|
||||||
|
if ( (i < (count-1)) )
|
||||||
|
currPath += wxFILE_SEP_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (noErrors == 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
return ::wxMkdir( dir, perm );
|
return ::wxMkdir( dir, perm );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user