mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
vlib: use new filename format
This commit is contained in:
parent
e64db44bb5
commit
dc4db87be3
45 changed files with 0 additions and 26 deletions
40
vlib/os2/os2_darwin.c.v
Normal file
40
vlib/os2/os2_darwin.c.v
Normal file
|
@ -0,0 +1,40 @@
|
|||
module os2
|
||||
|
||||
#include <fcntl.h>
|
||||
struct File {
|
||||
fd int
|
||||
}
|
||||
|
||||
fn C.perror(charptr)
|
||||
|
||||
|
||||
fn C.open(byteptr, int, int) int
|
||||
|
||||
|
||||
fn C.write(voidptr, byteptr, int) int
|
||||
|
||||
|
||||
fn C.close(int) int
|
||||
|
||||
|
||||
pub fn create(path string) ?File {
|
||||
fd := C.open(path.str, C.O_CREAT | C.O_TRUNC | C.O_WRONLY, 0644) // 511
|
||||
if fd == -1 {
|
||||
return error('failed to create "$path":')
|
||||
// os.print_c_errno()
|
||||
}
|
||||
return File{
|
||||
fd}
|
||||
}
|
||||
|
||||
pub fn (f File) writeln(s string) {
|
||||
ss := s + '\n'
|
||||
ret := C.write(f.fd, ss.str, s.len + 1)
|
||||
if ret == -1 {
|
||||
C.perror('failed to write')
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (f File) close() {
|
||||
C.close(f.fd)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue