Delphi: save a folder with files using Synopse Big Table
Question
How can I save a whole folder with it's files and folders using Synopse Big Table? I need to make a backup of my files without compression. I heard that Synopse Big Table is good for this purpose. But I couldn't find info to accomplish that.
Thanks!
La solution
Why didn't you write this question in the library forum?
OK, here is some sample code:
function SaveFolderToBigTableFile(const aFolder, aFile: TFileName): boolean;
var SR: TSearchRec;
BT: TSynBigTableString;
aPath: TFileName;
Path: RawUTF8;
begin
DeleteFile(aFile);
result := true;
BT := TSynBigTableString.Create(aFile);
try
aPath := ExtractFilePath(aFolder);
Path := StringToUTF8(aPath);
if FindFirst(aPath+'*.*',faAnyFile,SR)=0 then
try
repeat
if (SR.Name[1]='.') or (faDirectory and SR.Attr<>0) then
Continue;
if BT.Add(StringFromFile(aPath+SR.Name),StringToUTF8(SR.Name))<>0 then
writeln(SR.Name,' added') else begin
result := false;
writeln(SR.Name,' ERROR');
end;
if BT.CurrentInMemoryDataSize>100000000 then
BT.UpdateToFile;
until FindNext(SR)<>0;
finally
FindClose(SR);
end;
finally
BT.Free;
end;
end;
The trick is to use a TSynBigTableString
class using the file name as key.
You can add very fast compression just by using our SynLZ library (much faster than zip, but of course with a bit less compression ratio).
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow