Is it possible to get the current directory without using api ? Something which would be usable on linux and on windows ? I'm not sure if a PB function exist for this, i haven't see it
Thanks !


Code: Select all
; Procedure that return CurrentDir as String
Procedure.s GetCurrentDirectory()
currentdir.s = Space(255) ; <- 255 is defined as #MAX_PATH in Window, not Linux, oh well.
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
getcwd_(@currendir, 255)
If Right(currentdir, 1) <>"/" : currentdir + "/" : EndIf
CompilerElse
GetCurrentDirectory_(255, @CD)
If Right(currentdir,1)<>"\" : currentdir + "\" : EndIf
CompilerEndIf
ProcedureReturn currentdir
EndProcedure