program graphScan;
uses GraphABC;
type
_folder = class
private
path : string;
name : string;
countFiles : integer;
countFolders : integer;
pathToFiles : array of string;
pathToFolders : array of string;
fileName : array of string;
folderName : array of string;
reservedData : array of _folder; // for other folders
public
constructor Create(pth : string);
begin
path := pth;
end;
procedure collectData();
procedure outputData(n : integer);
procedure outputDataGraph(x, y, rad, inputRad : integer);
end;
procedure _folder.collectData();
begin
var dataClass := new System.IO.DirectoryInfo(path);
name := dataClass.Name;
var subFolders := dataClass.GetDirectories;
var subFiles := dataClass.GetFiles;
if ( length(subFiles) > 0 ) then
for var i := 0 to length(subFiles)-1 do begin
setlength(pathToFiles, length(pathToFiles)+1);
setlength(fileName, i+1);
fileName[i] := subFiles[i].Name;
pathToFiles[length(pathToFiles)-1] := subFiles[i].FullName;
end;
if ( length(subFolders) > 0 ) then
for var i := 0 to length(subFolders)-1 do begin
setlength(pathToFolders, i+1);
setlength(folderName, i+1);
pathToFolders[i] := subFolders[i].FullName;
folderName[i] := subFolders[i].Name;
setlength(reservedData, i+1);
if (folderName[i].Chars[1] <> '$') then begin
reservedData[i] := new _folder(pathToFolders[i]);
reservedData[i].collectData();
end;
end;
countFiles := length(subFiles);
countFolders := length(subFolders);
SubFiles := nil;
SubFolders := nil;
dataClass := nil;
end;
procedure _folder.outputData(n : integer);
begin
for var i := 0 to countFolders-1 do begin
var str := '--' * n;
writeln(str,'',folderName[i]);
if (length(reservedData) > 0) then
if (folderName[i].Chars[1] <> '$') then
reservedData[i].outputData(n+1);
end;
end;
procedure _folder.outputDataGraph(x, y, rad, InputRad : integer);
begin;
var Rx, Ry : array of integer;
setlength(Rx, countFolders);
setlength(Ry, countFolders);
setbrushcolor(argb(200,255,255,255));
setpencolor(argb(180,0,0,0));
for var i := 0 to countFolders-1 do
if (folderName[i].Chars[1] <> '$') then begin
Rx[i] := round( rad * (cos((360/countFolders ) + 55 * i * (pi/180) ) ));
Ry[i] := round( rad * (sin((360/countFolders ) + 55 * i * (pi/180) ) ));
//fillcircle(x + Rx[i], y + Ry[i], InputRad);
if (length(reservedData) > 0) then
if (folderName[i].Chars[1] <> '$') then
reservedData[i].outputDataGraph(x + Rx[i], y + Ry[i], round(rad/1.5), round(inputRad/1.4));
line(x, y, x + Rx[i], y + Ry[i], argb(100,50,50,50));
fillcircle(x + Rx[i], y + Ry[i], InputRad);
drawcircle(x + Rx[i], y + Ry[i], InputRad);
{for var j := 0 to countFiles-1 do begin
var a := random(360);
var xx := round( random(Inputrad) * (cos(a * (pi/180)) ));
var yy := round( random(inputrad) * (sin(a * (pi/180)) ));
putpixel(x+xx,y+yy,clred);
end;}
end;
end;
begin
SetSmoothingOff;
Window.Maximize;
writeln('Scanning file system on D:/');
var ScannedData := new _folder('D:');
ScannedData.collectData();
//ScannedData.outputData(1);
writeln('Drawing all data');
ScannedData.outputDataGraph(window.Center.X, window.Center.Y, 150, 25);
//for var i := 0 to ScannedData.countFolders-1 do
//writeln('-- ', ScannedData.pathToFolders[i]);
//var test := new System.IO.DirectoryInfo(root);
writeln('All complete in ', milliseconds/1000, ' seconds');
//readln();
end.