Skip to content

Commit 56c1c2d

Browse files
committed
ISO-9660: Implement file extraction
1 parent 8ccc35a commit 56c1c2d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

TotalImage.IO/FileSystems/ISO/IsoFile.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public override void MoveTo(string path)
7070
/// <inheritdoc />
7171
public override Stream GetStream()
7272
{
73-
throw new NotImplementedException();
73+
long offset = ((Iso9660FileSystem)FileSystem).PrimaryVolumeDescriptor.LogicalBlockSize * Record.ExtentOffset;
74+
var fileStream = new PartialStream(FileSystem.GetStream(), offset, Record.DataLength);
75+
return fileStream;
7476
}
7577

7678
/// <summary>

TotalImage/frmMain.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,11 @@ private void ExtractFiles(IEnumerable<TiFileSystemObject> items, string path, Se
20532053
}
20542054

20552055
using (var destStream = new FileStream(Path.Combine(path, file.Name), FileMode.Create))
2056+
using (var fileStream = file.GetStream())
2057+
{
2058+
fileStream.Position = 0; // reset position to zero because CopyTo will only go from current position
20562059
file.GetStream().CopyTo(destStream);
2060+
}
20572061

20582062
if (Settings.CurrentSettings.ExtractPreserveDates)
20592063
{

0 commit comments

Comments
 (0)