pub fn calc_seek_offset_isize(cur_offset: isize, pos: isize, whence: usize, buf_len: isize) -> Result<isize> {
    let new_offset = match whence {
        SEEK_CUR => pos.checked_add(cur_offset),
        SEEK_END => pos.checked_add(buf_len),
        SEEK_SET => Some(pos),
        _ => None,
    };

    match new_offset {
        Some(new_offset) if new_offset < 0 => Err(Error::new(EINVAL)),
        Some(new_offset) => Ok(cmp::min(new_offset, buf_len)),
        None => Err(Error::new(EOVERFLOW))
    }
}
/// Helper for seek calls
/// Result is guaranteed to be positive.
/// EOVERFLOW returned if the arguments would cause an overflow.
/// EINVAL returned if the new offset is out of bounds.
Helper for seek calls
Result is guaranteed to be positive.
EOVERFLOW returned if the arguments would cause an overflow.
EINVAL returned if the new offset is out of bounds.
Helper for seek calls Result is guaranteed to be positive . EOVERFLOW returned if the arguments would cause an overflow . EINVAL returned if the new offset is out of bounds .
pub fn calc_seek_offset_isize(cur_offset: isize, pos: isize, whence: usize, buf_len: isize) -> Result<isize> {
    let new_offset = match whence {
        SEEK_CUR => pos.checked_add(cur_offset),
        SEEK_END => pos.checked_add(buf_len),
        SEEK_SET => Some(pos),
        _ => None,
    };
    match new_offset {
        Some(new_offset) if new_offset < 0 => Err(Error::new(EINVAL)),
        Some(new_offset) => Ok(cmp::min(new_offset, buf_len)),
        None => Err(Error::new(EOVERFLOW))
    }
}
pub fn calc_seek_offset_isize ( cur_offset : isize , pos : isize , whence : usize , buf_len : isize ) -> Result < isize > { let new_offset = match whence { SEEK_CUR => pos . checked_add ( cur_offset ) , SEEK_END => pos . checked_add ( buf_len ) , SEEK_SET => Some ( pos ) , _ => None , } ; match new_offset { Some ( new_offset ) if new_offset < 0 => Err ( Error :: new ( EINVAL ) ) , Some ( new_offset ) => Ok ( cmp :: min ( new_offset , buf_len ) ) , None => Err ( Error :: new ( EOVERFLOW ) ) } }
Helper for seek calls
Result is guaranteed to be positive.
Helper for seek calls Result is guaranteed to be positive .
cur_offset
isize
pos
isize
whence
usize
buf_len
isize
cur_offset
isize
pos
isize
whence
usize
buf_len
isize