зеркало из https://github.com/mozilla/pjs.git
Added Recursive Copy routine
This commit is contained in:
Родитель
8a580e3ade
Коммит
31d5a62283
|
@ -172,6 +172,50 @@ void nsFileSpec::Delete(PRBool inRecursive) const
|
|||
remove(mPath);
|
||||
} // nsFileSpec::Delete
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::RecursiveCopy(nsFileSpec newDir) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (IsDirectory())
|
||||
{
|
||||
if (!(newDir.Exists()))
|
||||
{
|
||||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
for (nsDirectoryIterator i(*this); i.Exists(); i++)
|
||||
{
|
||||
nsFileSpec& child = (nsFileSpec&)i;
|
||||
|
||||
if (child.IsDirectory())
|
||||
{
|
||||
nsFileSpec tmpDirSpec(newDir);
|
||||
|
||||
char *leafname = child.GetLeafName();
|
||||
tmpDirSpec += leafname;
|
||||
nsCRT::free(leafname);
|
||||
|
||||
child.RecursiveCopy(tmpDirSpec);
|
||||
}
|
||||
else
|
||||
{
|
||||
child.RecursiveCopy(newDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!mPath.IsEmpty())
|
||||
{
|
||||
nsFileSpec& filePath = (nsFileSpec&) *this;
|
||||
|
||||
if (!(newDir.Exists()))
|
||||
{
|
||||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
filePath.Copy(newDir);
|
||||
}
|
||||
} // nsFileSpec::RecursiveCopy
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Rename(const char* inNewName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче