core :: NativeFile
core :: NativeFile :: defaultinit
core :: NativeFile :: feof
core :: NativeFile :: ferror
core :: NativeFile :: file_stat
core :: NativeFile :: fileno
core :: NativeFile :: io_close
core :: NativeFile :: io_open_read
core :: NativeFile :: io_open_write
core :: NativeFile :: native_stderr
core :: NativeFile :: native_stdin
core :: NativeFile :: native_stdout
core :: NativeFile :: set_buffering_type
Used to specify how the buffering will be handled for the current stream.core :: NativeFile :: write_byte
core $ NativeFile :: SELF
Type of this instance, automatically specialized in every classcore :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Pointer :: defaultinit
core :: Object :: defaultinit
core :: NativeFile :: defaultinit
core :: NativeFile :: feof
core :: NativeFile :: ferror
core :: NativeFile :: file_stat
core :: NativeFile :: fileno
core :: NativeFile :: io_close
core :: NativeFile :: io_open_read
core :: NativeFile :: io_open_write
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Pointer :: native_equals
core :: NativeFile :: native_stderr
core :: NativeFile :: native_stdin
core :: NativeFile :: native_stdout
core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Pointer :: premultiply_alpha
Multiply RGB values by their alpha valuecore :: NativeFile :: set_buffering_type
Used to specify how the buffering will be handled for the current stream.core :: NativeFile :: write_byte
# 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