mkFAT32 use a anytype stream

This allows mkFAT32 to work on a File or a fixedBufferStream or any streram that allows for reader(), writer() or seekableStream() interfaces.
This commit is contained in:
DrDeano 2020-11-09 19:06:31 +00:00
parent d9e776e898
commit 4f47409af6
No known key found for this signature in database
GPG key ID: 96188600582B9ED7
2 changed files with 49 additions and 49 deletions

View file

@ -211,7 +211,13 @@ const Fat32BuilderStep = struct {
///
fn make(step: *Step) (error{EndOfStream} || File.OpenError || File.ReadError || File.WriteError || File.SeekError || Fat32.Error)!void {
const self = @fieldParentPtr(Fat32BuilderStep, "step", step);
try Fat32.make(self.options, self.out_file_path);
// Open the out file
const image = try std.fs.cwd().createFile(self.out_file_path, .{ .read = true });
// If there was an error, delete the image as this will be invalid
errdefer (std.fs.cwd().deleteFile(self.out_file_path) catch unreachable);
defer image.close();
try Fat32.make(self.options, image);
}
///