func Feof(stream *File) int32 {
	buf := make([]byte, 1)
	_, err := stream.OsFile.Read(buf)
	result := 0
	if err == io.EOF {
		result = 1
	}
	stream.OsFile.Seek(-1, 1)
	return int32(result)
}
Feof handles feof().

Checks whether the end-of-File indicator associated with stream is set,
returning a value different from zero if it is.

This indicator is generally set by a previous operation on the stream that
attempted to read at or past the end-of-file.

Notice that stream's internal position indicator may point to the end-of-file
for the next operation, but still, the end-of-file indicator may not be set
until an operation attempts to read at that point.

This indicator is cleared by a call to clearerr, rewind, fseek, fsetpos or
freopen. Although if the position indicator is not repositioned by such a
call, the next i/o operation is likely to set the indicator again.
package noarch
import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"reflect"
	"strings"
)
var (
	Stdin  = NewFile(os.Stdin)
	Stdout = NewFile(os.Stdout)
	Stderr = NewFile(os.Stderr)
)
type File struct {
	OsFile *os.File
}
func Fopen(filePath, mode []byte) *File {
	var file *os.File
	var err error
	sFilePath := CStringToString(filePath)
	switch CStringToString(mode) {
	case "r":
		file, err = os.OpenFile(sFilePath, os.O_RDONLY, 0655)
	case "r+":
		file, err = os.OpenFile(sFilePath, os.O_RDWR, 0655)
	case "a":
		file, err = os.OpenFile(sFilePath, os.O_WRONLY|os.O_APPEND, 0655)
	case "a+":
		file, err = os.OpenFile(sFilePath, os.O_RDWR|os.O_APPEND, 0655)
	case "w":
		file, err = os.OpenFile(sFilePath, os.O_RDWR|os.O_CREATE, 0655)
	case "w+":
		file, err = os.OpenFile(sFilePath, os.O_RDWR|os.O_CREATE, 0655)
	default:
		panic(fmt.Sprintf("unsupported file mode: %s", mode))
	}
	if err != nil {
		return nil
	}
	return NewFile(file)
}
func Fclose(f *File) int32 {
	err := f.OsFile.Close()
	if err != nil {
		return 1
	}
	return 0
}
func Remove(filePath []byte) int32 {
	if os.Remove(CStringToString(filePath)) != nil {
		return -1
	}
	return 0
}
func Rename(oldName, newName []byte) int32 {
	from := CStringToString(oldName)
	to := CStringToString(newName)
	if os.Rename(from, to) != nil {
		return -1
	}
	return 0
}
func Fputs(str []byte, stream *File) int32 {
	if stream == nil {
		return -1
	}
	s := CStringToString(str)
	n, err := stream.OsFile.WriteString(s)
	if err != nil {
		panic(err)
	}
	return int32(n)
}
func Tmpfile() *File {
	f, err := ioutil.TempFile("", "")
	if err != nil {
		return nil
	}
	return NewFile(f)
}
func Fgets(str []byte, num32 int32, stream *File) []byte {
	num := int(num32)
	buf := make([]byte, num)
	n, err := stream.OsFile.Read(buf)
	if err != nil {
		return []byte{}
	}
	if n == num {
		return buf[:n-1]
	}
	return buf[:n]
}
func Gets(str []byte) []byte {
	_, err := Stdin.OsFile.Read(str)
	if err != nil {
		return []byte{}
	}
	return str
}
func Rewind(stream *File) {
	stream.OsFile.Seek(0, 0)
}