Property definitions

core $ NativeFile :: defaultinit
# Instance of this class are standard FILE * pointers
private extern class NativeFile `{ FILE* `}
	fun io_read(buf: CString, len: Int): Int `{
		return fread(buf, 1, len, self);
	`}

	fun io_write(buf: CString, from, len: Int): Int `{
		size_t res = fwrite(buf+from, 1, len, self);
#ifdef _WIN32
		// Force flushing buffer because end of line does not trigger a flush
		fflush(self);
#endif
		return (long)res;
	`}

	fun write_byte(value: Int): Int `{
		unsigned char b = (unsigned char)value;
		return fwrite(&b, 1, 1, self);
	`}

	fun io_close: Int `{ return fclose(self); `}

	fun file_stat: NativeFileStat `{
		struct stat buff;
		if(fstat(fileno(self), &buff) != -1) {
			struct stat* stat_element;
			stat_element = malloc(sizeof(struct stat));
			return memcpy(stat_element, &buff, sizeof(struct stat));
		}
		return 0;
	`}

	fun ferror: Bool `{ return ferror(self); `}

	fun feof: Bool `{ return feof(self); `}

	fun fileno: Int `{ return fileno(self); `}

	# Flushes the buffer, forcing the write operation
	fun flush: Int `{ return fflush(self); `}

	# Used to specify how the buffering will be handled for the current stream.
	fun set_buffering_type(buf_length, mode: Int): Int `{
		return setvbuf(self, NULL, (int)mode, buf_length);
	`}

	new io_open_read(path: CString) `{ return fopen(path, "r"); `}

	new io_open_write(path: CString) `{ return fopen(path, "w"); `}

	new native_stdin `{ return stdin; `}

	new native_stdout `{ return stdout; `}

	new native_stderr `{ return stderr; `}
end
lib/core/file.nit:1514,1--1569,3