summaryrefslogtreecommitdiff
path: root/src/video-support/util.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/video-support/util.vala')
-rw-r--r--src/video-support/util.vala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/video-support/util.vala b/src/video-support/util.vala
new file mode 100644
index 0000000..ad06680
--- /dev/null
+++ b/src/video-support/util.vala
@@ -0,0 +1,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;
+ }
+ }
+}