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:
parent
5d978d07a4
commit
f0ce340942
@ -166,9 +166,10 @@ public:
|
||||
// get a temp file name starting with thespecified prefix
|
||||
void AssignTempFileName( const wxString &prefix );
|
||||
|
||||
// directory creation and removal
|
||||
bool Mkdir( int perm = 0777 );
|
||||
static bool Mkdir( const wxString &dir, int perm = 0777 );
|
||||
// directory creation and removal.
|
||||
// if full is TRUE, will try to make each directory in the path.
|
||||
bool Mkdir( int perm = 0777, bool full = FALSE);
|
||||
static bool Mkdir( const wxString &dir, int perm = 0777, bool full = FALSE );
|
||||
|
||||
bool Rmdir();
|
||||
static bool Rmdir( const wxString &dir );
|
||||
|
@ -204,14 +204,46 @@ void wxFileName::AssignTempFileName( const wxString &prefix )
|
||||
// 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 )
|
||||
{
|
||||
return ::wxMkdir( dir, perm );
|
||||
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 );
|
||||
}
|
||||
|
||||
bool wxFileName::Rmdir()
|
||||
|
Loading…
Reference in New Issue
Block a user