summaryrefslogtreecommitdiff
path: root/src/video-support/util.vala
blob: ad06680980a28bf43babe0fe94289d02e4dd2e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Breaks a uint64 skip amount into several smaller skips.
public void skip_uint64(InputStream input, uint64 skip_amount) throws GLib.Error {
    while (skip_amount > 0) {
        // skip() throws an error if the amount is too large, so check against ssize_t.MAX
        if (skip_amount >= ssize_t.MAX) {
            input.skip(ssize_t.MAX);
            skip_amount -= ssize_t.MAX;
        } else {
            input.skip((size_t) skip_amount);
            skip_amount = 0;
        }
    }
}