Added ErrReadNotFile to ReatAt, WriteTo
This commit is contained in:
+7
-1
@@ -71,12 +71,18 @@ func (f File) Read(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f File) ReadAt(p []byte, off int64) (int, error) {
|
func (f File) ReadAt(p []byte, off int64) (int, error) {
|
||||||
|
if f.i.Type != inode.Fil && f.i.Type != inode.EFil {
|
||||||
|
return 0, ErrReadNotFile
|
||||||
|
}
|
||||||
return f.fullRdr.ReadAt(p, off)
|
return f.fullRdr.ReadAt(p, off)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteTo writes all data from the file to the writer. This is multi-threaded.
|
// WriteTo writes all data from the file to the writer. This is multi-threaded.
|
||||||
// The underlying reader is seperate from the one used with Read and can be reused.
|
// The underlying reader is seperate from the one used with Read and can be reused.
|
||||||
func (f File) WriteTo(w io.Writer) (int64, error) {
|
func (f File) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
if f.i.Type != inode.Fil && f.i.Type != inode.EFil {
|
||||||
|
return 0, ErrReadNotFile
|
||||||
|
}
|
||||||
return f.fullRdr.WriteTo(w)
|
return f.fullRdr.WriteTo(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ func (f *File) Close() error {
|
|||||||
// If n <= 0 all fs.DirEntry's are returned.
|
// If n <= 0 all fs.DirEntry's are returned.
|
||||||
func (f *File) ReadDir(n int) (out []fs.DirEntry, err error) {
|
func (f *File) ReadDir(n int) (out []fs.DirEntry, err error) {
|
||||||
if !f.IsDir() {
|
if !f.IsDir() {
|
||||||
return nil, errors.New("File is not a directory")
|
return nil, errors.New("file is not a directory")
|
||||||
}
|
}
|
||||||
ents, err := f.r.readDirectory(f.i)
|
ents, err := f.r.readDirectory(f.i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user