1
0
mirror of https://github.com/akpaevj/executor-scripts.git synced 2024-11-28 09:33:50 +02:00
akpaevj-executor-scripts/Zip.sbsl

24 lines
765 B
Plaintext
Raw Normal View History

2024-02-19 22:13:42 +02:00
#required IO.sbsl
2024-02-17 22:19:54 +02:00
@Global
2024-02-19 22:13:42 +02:00
method ZipFolder(FolderPath: String, ArchivePath: String, ZipChildren: Boolean = True)
val Folder = new File(FolderPath)
val Archive = new File(ArchivePath)
var Writer = new ZipWriter(Archive.OpenWritableStream())
2024-02-17 22:19:54 +02:00
2024-02-19 22:13:42 +02:00
if ZipChildren
2024-02-19 22:18:14 +02:00
Folder.Children.ForEach(Child -> AddToZipArchive(Child, Writer))
2024-02-19 22:13:42 +02:00
else
AddToZipArchive(Folder, Writer)
2024-02-17 22:19:54 +02:00
;
Writer.Write()
;
2024-02-19 22:13:42 +02:00
method AddToZipArchive(FileToZipping: File, Writer: ZipWriter, Path: String = "")
if FileToZipping.IsFile()
Writer.Add(FileToZipping.OpenReadableStream(), IO.JoinPath(Path, FileToZipping.Name))
else
2024-02-19 22:18:14 +02:00
FileToZipping.Children.ForEach(Child -> AddToZipArchive(Child, Writer, IO.JoinPath(Path, FileToZipping.Name)))
2024-02-17 22:19:54 +02:00
;
;