1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: re-apply C++ support

This commit is contained in:
Uwe Krüger
2020-05-18 21:38:06 +02:00
committed by GitHub
parent 895cefe351
commit 2635be511f
33 changed files with 261 additions and 150 deletions

View File

@@ -84,6 +84,7 @@ pub fn open(path string) ?File {
*/
file := File{
cfile: C.fopen(charptr(path.str), 'rb')
fd: 0
opened: true
}
if isnil(file.cfile) {
@@ -119,6 +120,7 @@ pub fn create(path string) ?File {
*/
file := File{
cfile: C.fopen(charptr(path.str), 'wb')
fd: 0
opened: true
}
if isnil(file.cfile) {
@@ -207,7 +209,8 @@ pub fn exec(cmd string) ?Result {
buf := [4096]byte
mut res := strings.new_builder(1024)
for C.fgets(charptr(buf), 4096, f) != 0 {
res.write_bytes( buf, vstrlen(buf) )
bufbp := byteptr(buf)
res.write_bytes( bufbp, vstrlen(bufbp) )
}
soutput := res.str().trim_space()
//res.free()
@@ -216,8 +219,8 @@ pub fn exec(cmd string) ?Result {
// return error(res)
// }
return Result{
output: soutput
exit_code: exit_code
output: soutput
}
}