Page 1 of 1

[Implemented] GetCurrentDirectory()

Posted: Thu Nov 17, 2005 5:29 pm
by naw
Hi,
It appears that the only way to get the Current Working Directory name is like this:

Code: Select all

curPath.s=Space(#MAX_PATH)
GetCurrentDirectory_(#MAX_PATH,@curPath)
curPath+"\"
- which is fine, but only available for Windows. Can we please have a legitimate X-Platform PB command to do the same

Determine the current working directory

Posted: Mon Dec 12, 2005 10:18 pm
by phillip
If your using linux you can always write the envirorment varable to the file, open and read the varable. Just type export to find it.

Phillip Taylor

Posted: Tue Dec 13, 2005 1:09 am
by naw
Hi Phillip,
- Yes thats a good idea. But for sucha simple function, it would be nice to have a native PB command. That would cross-compile.

Posted: Tue Dec 13, 2005 1:26 am
by ts-soft
You can use this:

Code: Select all

Procedure.s GetCurrentDir()
  Protected CurDir.s
  CurDir.s = Space(2048)
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    getcwd_(CurDir, 2048)
  CompilerElse 
    GetCurrentDirectory_(2048,CurDir)
  CompilerEndIf
  ProcedureReturn CurDir
EndProcedure

Debug GetCurrentDir()