mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: it can now be used for _platform.v files too, no matter the host os
This commit is contained in:

committed by
Alexander Medvednikov

parent
84fbd5b3d0
commit
6c16bac908
@ -1,22 +1,31 @@
|
||||
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.creat(path.str, 0644)//511)
|
||||
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()
|
||||
// os.print_c_errno()
|
||||
}
|
||||
return File{fd}
|
||||
}
|
||||
return File{
|
||||
fd}
|
||||
}
|
||||
|
||||
pub fn (f File) writeln(s string) {
|
||||
ss := s + '\n'
|
||||
@ -29,4 +38,3 @@ pub fn (f File) writeln(s string) {
|
||||
pub fn (f File) close() {
|
||||
C.close(f.fd)
|
||||
}
|
||||
|
Reference in New Issue
Block a user