http://www.villavu.com/forum/showthread.php?t=45824
Heres the script I use:
SCAR Code:
function DownloadRepository(RepositoryURL, InstallPath : string; Overwrite : boolean) : boolean;
var
s : string;
Files, Folders, Contents : TStringArray;
i, h, z : integer;
FileNum : integer;
begin
SetArrayLength(Folders, 1);
Folders[0] := RepositoryURL;
Writeln('Obtaining file list...');
repeat
s := GetPage(Folders[i]);
s := Replace(s, 'a href="../">', '');
repeat
h := High(Files);
SetArrayLength(Files, h + 2);
h := h + 1;
Files[h] := Folders[i] + Between('href="', '">', s);
s := Replace(s, 'href="' + Between('href="', '">', s) + '">', '');
if pos('http://', Copy(Files[h], 8, Length(Files[h]))) > 0 then
break;
if EndsWith('/', Files[h]) then
begin
h := high(Folders);
SetArrayLength(Folders, h + 2);
h := high(Folders);
Files[high(files)] := Replace(Files[high(files)], RepositoryURL, '');
Folders[h] := RepositoryURL + Files[high(files)];
SetArrayLength(Files, GetArrayLength(Files) - 1);
end;
until(false);
SetArrayLength(Files, GetArrayLength(Files) - 1);
inc(i);
until(i = high(Folders) + 1);
h := high(Files);
Writeln('Obtained file and folder list. There are ' + IntToStr(High(Folders)) + ' folders and ' + IntToStr(h + 1) + ' files.');
Writeln('Downloading and installing files...');
h := high(Files);
SetArrayLength(Contents, h + 1);
for i := 0 to h do
begin
if ((FileExists(InstallPath + Files[i])) and (not Overwrite)) then
Continue;
Contents[i] := GetPage(Files[i]);
Files[i] := Replace(Files[i], RepositoryURL, '') ;
Files[i] := Replace(Files[i], '/', '\');
Files[i] := Replace(Files[i], '%20', ' ');
writeln(InstallPath + Files[i]);
FileNum := RewriteFile(InstallPath + Files[i], true);
try
WriteFileString(FileNum, Contents[i]);
except
Writeln('Failed installing file ' + Files[i] + '!');
finally
CloseFile(FileNum);
end;
end;
wait(500);
Writeln('Verifying all files and contents...');
for i := 0 to h do
begin
if Length(Contents[i]) = 0 then
Continue;
if FileExists(InstallPath + Files[i]) then
begin
FileNum := OpenFile(InstallPath + Files[i], true);
if FileSize(FileNum) <> Length(Contents[i]) then
begin
inc(z);
Writeln(Files[i] + ' was not installed successfully.');
end;
CloseFile(FileNum);
end else
begin
inc(z);
Writeln(Files[i] + ' was not installed successfully.');
end;
end;
if z <> 0 then
Writeln(IntToStr(z) + ' file(s) were/was not installed successfully!')
else
begin
Writeln('All files were installed successfully.');
result := true;
end;
end;
begin
DownloadRepository('http://scardevreflection.googlecode.com/svn/trunk/', AppPath + 'Includes\SRL\SRL\Reflection\', True);
end.