mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-10-26 09:54:23 +03:00
Merge pull request #4526 from doofin/master
add `get current directory name`
This commit is contained in:
commit
86126a72fa
@ -375,3 +375,9 @@ changeDir : String -> IO Bool
|
||||
changeDir dir
|
||||
= do ok <- foreign FFI_C "idris_chdir" (String -> IO Int) dir
|
||||
pure (ok == 0)
|
||||
|
||||
export
|
||||
currentDir : IO String
|
||||
currentDir = do
|
||||
MkRaw s <- foreign FFI_C "idris_currentDir" (IO (Raw String))
|
||||
pure s
|
||||
|
@ -259,3 +259,11 @@ VAL idris_getString(VM* vm, void* buffer) {
|
||||
free(sb);
|
||||
return str;
|
||||
}
|
||||
|
||||
VAL idris_currentDir() {
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL)
|
||||
return MKSTR(get_vm(),cwd);
|
||||
else
|
||||
return MKSTR(get_vm(),"");
|
||||
}
|
||||
|
@ -55,4 +55,6 @@ VAL idris_time();
|
||||
|
||||
void idris_forceGC();
|
||||
|
||||
VAL idris_currentDir();
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user