-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebf8420
commit 28fb37a
Showing
4 changed files
with
124 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using SharpCompress.Common; | ||
using SharpCompress.Readers; | ||
|
||
namespace NewRGB.Data; | ||
|
||
public class InstallProgress(string dir, FileStream fileStream, IReader reader, string zip) | ||
{ | ||
public static async Task<InstallProgress> Install(string dir, string zip) | ||
{ | ||
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); | ||
var fileStream = File.OpenRead(zip); | ||
var reader = await Task.Run(() => ReaderFactory.Open(fileStream)); | ||
return new InstallProgress(dir, fileStream, reader, zip); | ||
} | ||
|
||
public async Task Run() | ||
{ | ||
var opt = new ExtractionOptions | ||
{ | ||
ExtractFullPath = true, | ||
Overwrite = true | ||
}; | ||
while (await Task.Run(reader.MoveToNextEntry)) | ||
if (!reader.Entry.IsDirectory) | ||
await Task.Run(() => reader.WriteEntryToDirectory(dir, opt)); | ||
} | ||
|
||
public async Task End() | ||
{ | ||
reader.Dispose(); | ||
await fileStream.DisposeAsync(); | ||
File.Delete(zip); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters