mirror of
https://github.com/akpaevj/executor-scripts.git
synced 2024-11-24 08:52:35 +02:00
32 lines
937 B
Plaintext
32 lines
937 B
Plaintext
#required Path.sbsl
|
|
#required Path.sbsl
|
|
|
|
@Global
|
|
method CreateFromDirectory(StartPath: String, ZipPath: String)
|
|
val Folder = new File(StartPath)
|
|
val Archive = new File(ZipPath)
|
|
var Writer = new ZipWriter(Archive.OpenWritableStream())
|
|
|
|
Folder.Children.ForEach(Child -> AddToZipArchive(Child, Writer))
|
|
|
|
Writer.Write()
|
|
;
|
|
|
|
@Global
|
|
method ExtractToDirectory(ZipPath: String, ExtractPath: String)
|
|
val Archive = new ZipFile(ZipPath)
|
|
|
|
if not Path.Exists(ExtractPath)
|
|
Files.CreateDirectory(ExtractPath)
|
|
;
|
|
|
|
Archive.ExtractAll(ExtractPath)
|
|
;
|
|
|
|
method AddToZipArchive(FileToZipping: File, Writer: ZipWriter, RelativePath: String = "")
|
|
if FileToZipping.IsFile()
|
|
Writer.Add(FileToZipping.OpenReadableStream(), Path.Join(RelativePath, FileToZipping.Name))
|
|
else
|
|
FileToZipping.Children.ForEach(Child -> AddToZipArchive(Child, Writer, Path.Join(RelativePath, FileToZipping.Name)))
|
|
;
|
|
; |