- Code: Select all
var currentDir = arguments[0];
var allDirectories = arguments[1];
var thisDir = new Array();
var dirContents = plugins.file.getFolderContents( currentDir );
var dirCount = dirContents.length;
for ( var i = 0; i < dirCount; i++)
{
if( dirContents[i].isDirectory() )
{
var next = thisDir.length;
thisDir[next] = dirContents[i];
}
else
{
globals.gDirSize += dirContents[i].size();
}
}
for (j = 0; j < thisDir.length; j++)
{
var next2 = allDirectories.length;
allDirectories[next2] = thisDir[j];
globals.gGetDirSize(thisDir[j], allDirectories);
}
return 1;
The method works as it should for folders that are not deeply nested. When things get too deep, however, I get the following error message:
Cycle detected, function gGetDirSize called 7 times (gGetDirSize, line 27)
It's great that Servoy can catch unrestricted infinite loops, but shouldn't there be a legitimate way to use this kind of recursive function?
Has anyone else wrestled with this and found a solution or workaround?
Thanks...
bill