Created
October 6, 2019 13:32
-
-
Save SamTebbs33/bf3a9c27865214172c3e6dd28f21cee6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const std = @import("std"); | |
| var f: std.fs.File = undefined; | |
| pub fn main() !void { | |
| f = try std.fs.File.openRead("zig-cache/bin/iso/boot/pluto.elf"); | |
| const S = struct { | |
| const SStream = std.io.SeekableStream(anyerror, anyerror); | |
| const IStream = std.io.InStream(anyerror); | |
| var sstream = SStream{ | |
| .seekToFn = seekTo, | |
| .seekByFn = seekBy, | |
| .getPosFn = getPos, | |
| .getEndPosFn = getEndPos, | |
| }; | |
| var istream = IStream{ .readFn = read }; | |
| fn seekTo(self: *SStream, pos: u64) anyerror!void { | |
| return f.seekTo(pos); | |
| } | |
| fn seekBy(self: *SStream, pos: i64) anyerror!void { | |
| return f.seekBy(pos); | |
| } | |
| fn getPos(self: *SStream) anyerror!u64 { | |
| return f.getPos(); | |
| } | |
| fn getEndPos(self: *SStream) anyerror!u64 { | |
| return f.getEndPos(); | |
| } | |
| fn read(self: *IStream, buffer: []u8) anyerror!usize { | |
| return f.read(buffer); | |
| } | |
| }; | |
| var elf = try std.debug.openElfDebugInfo(std.heap.direct_allocator, &S.sstream, &S.istream); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment