From e9c00c3d39e517079f46924da0f7f63b17fc9ef0 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Sat, 29 Jun 2019 17:28:17 +1000 Subject: [PATCH] Windows: Implement getwd() & make ls() public. --- os/os_win.v | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/os/os_win.v b/os/os_win.v index df18d798e4..bbb18861c9 100644 --- a/os/os_win.v +++ b/os/os_win.v @@ -4,11 +4,22 @@ module os -fn ls(path string) []string { +pub fn ls(path string) []string { mut res := []string return res } +pub fn getwd() string { + mut buffer := malloc(512) + + buffer = C._getcwd(0, 0) + // A NULL return value indicates an error + if isnil(buffer) { + return '' + } + return string(buffer) +} + const ( FILE_ATTRIBUTE_DIRECTORY = 16 ) @@ -22,11 +33,6 @@ fn chdir(path string) { C._chdir(path.cstr()) } -fn getwd() string { - panic('getwd() not impl') - return '' -} - fn log(s string) { }