Commit 0f590ee0 authored by John van Groningen's avatar John van Groningen

fix GetCurrentDirectory, remove zero char at end,

winapi function GetCurrentDirectory yields the size WITHOUT the zero char at the end,
but when called with NULL and 0 it yields the size WITH the zero char at the end
parent 5869d2b0
......@@ -159,10 +159,15 @@ where
GetCurrentDirectory :: (!Bool,!String)
GetCurrentDirectory
#! buff_size = GetCurrentDirectory_ 0 "\0"
#! buffer = createArray buff_size '\0'
#! result = GetCurrentDirectory_ buff_size buffer
= (result <> 0, buffer)
// GetCurrentDirectory yields the size without the zero char, except when called with NULL and 0 !
#! buffer_size_including_zero_char = GetCurrentDirectory_ 0 "\0"
#! buffer = createArray buffer_size_including_zero_char '\0'
#! n_chars_without_zero_char = GetCurrentDirectory_ buffer_size_including_zero_char buffer
| n_chars_without_zero_char==0
= (False,"")
| size buffer>0 && buffer.[size buffer-1]=='\0'
= (True,buffer % (0,size buffer-2))
= (True,buffer)
where
GetCurrentDirectory_ :: !Int !String -> Int
GetCurrentDirectory_ buffer_size buffer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment