import errno


def readlocal(path, offset=None, size=-1):
    """
    Wrapper around open(path, 'rb') that returns the contents of the file as a string.

    Will rethrow FileNotFoundError if it receives an IOError.
    """
    try:
        with open(path, 'rb') as f:
            if offset:
                f.seek(offset)
            buf = f.read(size)
    except IOError as e:
        if e.errno == errno.ENOENT:
            raise FileNotFoundError(e)
        else:
            raise
    return buf