in Core/src/Impl/Commands/CreateCommand.cs [134:160]
private static async Task WriteDataPacked(
string sourceFile,
string packedStorageRelativeFile,
Func<Stream, Task> writeStorageFile)
{
CabCompressionUtil.VerifyPlatformSupported();
// Note: packedStorageRelativeFile should be in following format: [cc/]aaa.bbb/<hash>/aaa.bb_
var filePathInArchive = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(packedStorageRelativeFile)));
if (filePathInArchive == null)
throw new ArgumentException("Incorrect file path in archive. Expected format: '[cc/]aaa.bbb/<hash>/aaa.bb_'", nameof(packedStorageRelativeFile));
var tempFile = Path.GetTempFileName();
try
{
CabCompressionUtil.CompressFile(tempFile,
new CompressionFileInfo(filePathInArchive, sourceFile)
);
await using var stream = File.Open(tempFile, FileMode.Open, FileAccess.Read);
await writeStorageFile(stream);
}
finally
{
File.Delete(tempFile);
}
}