Commit 2babcd59 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/fs1: Factor-out noEOF and okEOF into common place (-> internal/xio)

We will need to use those utilities for ZEO and NEO.
parent 774f12c3
// Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xio provides addons to standard package io.
package xio
import (
"io"
)
// NoEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF.
func NoEOF(err error) error {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return err
}
// EOFok returns err, but changes io.EOF -> nil.
func EOFok(err error) error {
if err == io.EOF {
err = nil
}
return err
}
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -20,27 +20,15 @@
package fs1
import (
"io"
"os"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/go123/xbufio"
)
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
func noEOF(err error) error {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return err
}
// okEOF returns err, but changes io.EOF -> nil
func okEOF(err error) error {
if err == io.EOF {
err = nil
}
return err
}
// noEOF and okEOF are syntactic sugar over xio.NoEOF and xio.EOFok.
func noEOF(err error) error { return xio.NoEOF(err) }
func okEOF(err error) error { return xio.EOFok(err) }
// record reading routines work on abstract file-like interfaces.
// when they report e.g. decoding error, if reader has name, e.g. as os.File
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment