parent
d226fa7b17
commit
78c706ab71
|
@ -329,8 +329,8 @@ pub fn (f mut File) close() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.opened = false
|
f.opened = false
|
||||||
//$if linux {
|
$if linux {
|
||||||
$if linux_or_macos {
|
//$if linux_or_macos {
|
||||||
C.syscall(sys_close, f.fd)
|
C.syscall(sys_close, f.fd)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,8 @@ pub fn is_dir(path string) bool {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub fn open(path string) ?File {
|
pub fn open(path string) ?File {
|
||||||
//$if linux {
|
$if linux {
|
||||||
$if linux_or_macos {
|
//$if linux_or_macos {
|
||||||
fd := C.syscall(sys_open, path.str, 511)
|
fd := C.syscall(sys_open, path.str, 511)
|
||||||
if fd == -1 {
|
if fd == -1 {
|
||||||
return error('failed to open file "$path"')
|
return error('failed to open file "$path"')
|
||||||
|
@ -95,8 +95,8 @@ pub fn open(path string) ?File {
|
||||||
|
|
||||||
// create creates a file at a specified location and returns a writable `File` object.
|
// create creates a file at a specified location and returns a writable `File` object.
|
||||||
pub fn create(path string) ?File {
|
pub fn create(path string) ?File {
|
||||||
//$if linux {
|
$if linux {
|
||||||
$if linux_or_macos {
|
//$if linux_or_macos {
|
||||||
mut fd := 0
|
mut fd := 0
|
||||||
//println('creat SYS')
|
//println('creat SYS')
|
||||||
$if macos {
|
$if macos {
|
||||||
|
@ -134,8 +134,8 @@ pub fn (f mut File) write(s string) {
|
||||||
if !f.opened {
|
if !f.opened {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//$if linux {
|
$if linux {
|
||||||
$if linux_or_macos {
|
//$if linux_or_macos {
|
||||||
C.syscall(sys_write, f.fd, s.str, s.len)
|
C.syscall(sys_write, f.fd, s.str, s.len)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -148,8 +148,8 @@ pub fn (f mut File) writeln(s string) {
|
||||||
if !f.opened {
|
if !f.opened {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$if linux_or_macos {
|
//$if linux_or_macos {
|
||||||
//$if linux {
|
$if linux {
|
||||||
snl := s + '\n'
|
snl := s + '\n'
|
||||||
C.syscall(sys_write, f.fd, snl.str, snl.len)
|
C.syscall(sys_write, f.fd, snl.str, snl.len)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue