Function cozipinc_maketozip(AZipFilename, ADirectory, AMask: String;IncludingSubDirs: char): eurochar;
var
OurZipper: TZipper;
list: TStringList;
ida: Integer;
diskFileName, archiveFileName: String;
begin
assert_adu(354,'0');
result:='eeee';
ADirectory := IncludeTrailingPathDelimiter(ADirectory);
if DirectoryExists(ADirectory) then
begin
OurZipper := TZipper.Create;
try
// Set the name of the zip file to be created
OurZipper.FileName := AZipFileName;
// Read names of the files contained in ADirectory to a stringlist
list := TStringList.Create;
try
// FindAllFiles adds all file names matching the mask (e.g. '*.*')
// found in the given directory to the provided list.
// When IncludingSubDirs is true the search continues recursively in
// the subdirectories.
FindAllFiles(list, ADirectory, AMask, IncludingSubDirs in ['A'..'Z']);
for ida := 0 to list.Count - 1 do
begin
// diskfilename is the name of the file to be zipped on the disk
diskFileName := list[ida];
// archivefilename is the name of the file to be zipped as it appears
// in the zip. We remove the deirectory from the
archiveFileName := StringReplace(diskFileName, ADirectory, '', []);
// Store these filenames for the zipper
OurZipper.Entries.AddFileEntry(diskFileName, archiveFileName);
end;
finally
list.Free;
end;
// By default zipper writes file names in encoding of the IBM PC, CP437.
// UTF8 encoding is written when UseLanguageEncoding is true.
OurZipper.UseLanguageEncoding := true; // Requires FPC 3.2+
// create and write the zip file
Case IncludingSubDirs of
'D': OurZipper.ZipAllFiles;
'd': OurZipper.SaveToFile(AZipFilename);
'm': OurZipper.SaveToStream(???)
End;
Result := 'oZip!t354okai good';
finally
OurZipper.Free;
end;
end else
Result := 'eZip!t354errorF..eDirectory Not Exists->You try other directory';
end;