diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-11-11 19:39:25 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-11-11 19:39:25 +0100 |
commit | f5b7ac49999b1d843176eedb3dc880e8977a5d64 (patch) | |
tree | a4341a5800fd9c8d83080fe8c79bd8b5c213bb6f /tools/wixl/util.vala | |
parent | eb625982d76390fd4de6f624dac1c9040b8472ee (diff) | |
download | msitools-f5b7ac49999b1d843176eedb3dc880e8977a5d64.tar.gz msitools-f5b7ac49999b1d843176eedb3dc880e8977a5d64.tar.xz msitools-f5b7ac49999b1d843176eedb3dc880e8977a5d64.zip |
wixl: add MsiFileHash table
Diffstat (limited to 'tools/wixl/util.vala')
-rw-r--r-- | tools/wixl/util.vala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/wixl/util.vala b/tools/wixl/util.vala index d91baca..ca2183c 100644 --- a/tools/wixl/util.vala +++ b/tools/wixl/util.vala @@ -168,6 +168,25 @@ namespace Wixl { return -1; } + public void compute_md5 (File file, ref int hash1, ref int hash2, ref int hash3, ref int hash4) throws GLib.Error { + var checksum = new Checksum (ChecksumType.MD5); + var stream = file.read (); + uint8 fbuf[4096]; + size_t size; + + while ((size = stream.read (fbuf)) > 0) { + checksum.update (fbuf, size); + } + + int buffer[4]; + size_t buflen = 16; + checksum.get_digest ((uint8[])buffer, ref buflen); + hash1 = buffer[0]; + hash2 = buffer[1]; + hash3 = buffer[2]; + hash4 = buffer[3]; + } + public class UnixInputStream : GLib.InputStream { public int fd { get; set construct; } |