Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Publish GUI application (Self-contained)
if: matrix.build-type == 'self-contained'
run: dotnet publish GDeflateGUI/GDeflateGUI.csproj --configuration Release --output ./publish-gui --self-contained true --runtime win-x64
run: dotnet publish GDeflateGUI/GDeflateGUI.csproj --configuration Release --output ./publish-gui --self-contained true --runtime win-x64 /p:PublishSingleFile=true /p:EnableCompressionInSingleFile=true

- name: Publish GUI application (Framework-dependent)
if: matrix.build-type == 'framework-dependent'
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
run: dotnet run --project GDeflateConsole --configuration Release test

- name: Publish console application (Self-contained)
run: dotnet publish GDeflateConsole/GDeflateConsole.csproj --configuration Release --output ./publish-console --self-contained true --runtime ${{ matrix.runtime }}
run: dotnet publish GDeflateConsole/GDeflateConsole.csproj --configuration Release --output ./publish-console --self-contained true --runtime ${{ matrix.runtime }} /p:PublishSingleFile=true /p:EnableCompressionInSingleFile=true

- name: Create build info (Windows)
if: matrix.os == 'windows-latest'
Expand Down
9 changes: 9 additions & 0 deletions GDeflateConsole/GDeflateConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@
<RootNamespace>GDeflateConsole</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Update="cudart64_12.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nvcomp64_3.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
20 changes: 17 additions & 3 deletions GDeflateConsole/GDeflateProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,19 @@ private void DecompressFileSimulation(string inputFile, string outputFile)
using (var input = new FileStream(inputFile, FileMode.Open))
{
var header = new byte[8];
input.Read(header, 0, 8);
ReadExactly(input, header, 0, 8);

if (System.Text.Encoding.UTF8.GetString(header) != "GDEF_SIM")
{
throw new InvalidDataException("File is not a simulated GDeflate file");
}

var sizeBytes = new byte[4];
input.Read(sizeBytes, 0, 4);
ReadExactly(input, sizeBytes, 0, 4);
int originalSize = BitConverter.ToInt32(sizeBytes, 0);

var storedData = new byte[Math.Min(originalSize, 1024)];
input.Read(storedData, 0, storedData.Length);
ReadExactly(input, storedData, 0, storedData.Length);

// Create output file with stored data repeated to match original size
using (var output = new FileStream(outputFile, FileMode.Create))
Expand All @@ -248,6 +248,20 @@ private void DecompressFileSimulation(string inputFile, string outputFile)
}
}

private static void ReadExactly(Stream stream, byte[] buffer, int offset, int count)
{
int totalBytesRead = 0;
while (totalBytesRead < count)
{
int bytesRead = stream.Read(buffer, offset + totalBytesRead, count - totalBytesRead);
if (bytesRead == 0)
{
throw new EndOfStreamException("End of stream reached before all bytes were read.");
}
totalBytesRead += bytesRead;
}
}

private void CheckCuda(int err)
{
if (err != 0)
Expand Down
9 changes: 9 additions & 0 deletions GDeflateGUI/GDeflateGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
<None Update="cudart64_12.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nvcomp64_3.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading