From c6424fbc55298399f133ca1ede11e1f0b4a5c824 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 29 Jul 2022 16:16:24 +0200 Subject: use a shared fs_normslice() function to handle offsets --- src/shared/include/camellia/fsutil.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/shared/include/camellia/fsutil.h (limited to 'src/shared/include') diff --git a/src/shared/include/camellia/fsutil.h b/src/shared/include/camellia/fsutil.h new file mode 100644 index 0000000..eb2b23e --- /dev/null +++ b/src/shared/include/camellia/fsutil.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +/** Normalizes the offset and length passed to a fs into safe values. + * If returns *length == 0, *offset is meaningless. + * + * @param expand Can this operation expand the target file? + * true if writing to a file with an adjustable size + * false if reading any sort of file + * or writing to a file with static size + */ +void fs_normslice(long *restrict offset, size_t *restrict length, size_t max, bool expand); -- cgit v1.2.3