func (f File) ReadDir(n int) ([]fs.DirEntry, error) {
	if !f.IsDir() {
		return nil, errors.New("File is not a directory")
	}
	ffs, err := f.FS()
	if err != nil {
		return nil, err
	}
	var beg, end int
	if n <= 0 {
		beg, end = 0, len(ffs.entries)
	} else {
		beg, end = f.dirsRead, f.dirsRead+n
		if end > len(ffs.entries) {
			end = len(ffs.entries)
			err = io.EOF
		}
	}
	out := make([]fs.DirEntry, end-beg)
	for i, ent := range ffs.entries[beg:end] {
		out[i] = f.r.newDirEntry(ent, ffs)
	}
	return out, err
}
ReadDir returns n fs.DirEntry's that's contained in the File (if it's a directory).
If n <= 0 all fs.DirEntry's are returned.
package squashfs
import (
	"errors"
	"io"
	"io/fs"
	"log"
	"os"
	"path"
	"strconv"
	"strings"
	"github.com/CalebQ42/squashfs/internal/directory"
	"github.com/CalebQ42/squashfs/internal/inode"
)
type File struct {
	i        *inode.Inode
	parent   *FS
	r        *Reader
	reader   *fileReader
	name     string
	dirsRead int
}
func (f FileInfo) File() (file *File, err error) {
	file = &File{
		name:   f.name,
		r:      f.r,
		parent: f.parent,
		i:      f.i,
	}
	if file.IsRegular() {
		file.reader, err = f.r.newFileReader(f.i)
	}
	return
}
func (d DirEntry) File() (file *File, err error) {
	return d.r.newFileFromDirEntry(d.en, d.parent)
}
func (r Reader) newFileFromDirEntry(en *directory.Entry, parent *FS) (file *File, err error) {
	file = &File{
		name:   en.Name,
		r:      &r,
		parent: parent,
	}
	file.i, err = r.getInodeFromEntry(en)
	if err != nil {
		return nil, err
	}
	if file.IsRegular() {
		file.reader, err = r.newFileReader(file.i)
	}
	return
}
func (f File) Stat() (fs.FileInfo, error) {
	return &FileInfo{
		i:      f.i,
		name:   f.name,
		parent: f.parent,
		r:      f.r,
	}, nil
}
func (f File) Read(p []byte) (int, error) {
	if f.i.Type == inode.FileType || f.i.Type == inode.ExtFileType {
		if f.reader == nil {
			return 0, fs.ErrClosed
		}
		return f.reader.Read(p)
	}
	return 0, errors.New("can only read files")
}
func (f File) WriteTo(w io.Writer) (int64, error) {
	if f.i.Type == inode.FileType || f.i.Type == inode.ExtFileType {
		if f.reader == nil {
			return 0, fs.ErrClosed
		}
		return f.reader.WriteTo(w)
	}
	return 0, errors.New("can only read files")
}
func (f *File) Close() error {
	f.reader = nil
	return nil
}