Set current dir at runtime

Maybe later we could have an option for this
This commit is contained in:
BigDave 2018-07-17 19:44:41 +01:00
parent a7b33fd4dc
commit 7dcf01fdf6
Signed by: BigDave
GPG Key ID: 2787C0A942BB86EC
2 changed files with 21 additions and 1 deletions

View File

@ -40,6 +40,7 @@
"files.associations": {
"ph7int.h": "c",
"ph7.h": "c",
"stdlib.h": "c"
"stdlib.h": "c",
"direct.h": "c"
}
}

View File

@ -184,6 +184,25 @@ int main(int argc, char **argv) {
PH7_VM_CONFIG_IMPORT_PATH,
"test"
);
char* cwd;
// Get the current working directory:
#ifdef __WINNT__
if((cwd = _getcwd( NULL, 0 )) == NULL)
#else
if((cwd = getcwd( NULL, 0 )) == NULL)
#endif
perror("_getcwd error");
else
{
printf("cwd: %s\n", cwd);
rc = ph7_vm_config(pVm,
PH7_VM_CONFIG_IMPORT_PATH,
cwd
);
free(cwd);
}
if(rc != PH7_OK) {
Fatal("Error while installing the VM output consumer callback");
}