
[Implemented] GetWorkingDirectory()
-
- PureBasic Expert
- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
[Implemented] GetWorkingDirectory()
This command would be very usefull for Linux, cause Linux depends a lot on other directories to store data and libraries, but unlike windows it does not seek the directory where the executable was launch itself 

hope that this code helps you.
put it at the beginning of the program
put it at the beginning of the program
Code: Select all
Global workdir$
workdir$=Space(255) : GetCurrentDirectory_(255,@workdir$)
...
(your code)
PB 6.21 beta, PureVision User
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
On Linux??!?zikitrake wrote:Code: Select all
Global workdir$ workdir$=Space(255) : GetCurrentDirectory_(255,@workdir$) ... (your code)
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Again..
If Someone is interested:
*EDIT Removed link (server down)
GetCurrentDirectory() For Linux, return a string
Download, rename and copy to purelibraries & test
Hope it works.. Just a quick lib I made..
If Someone is interested:
*EDIT Removed link (server down)
GetCurrentDirectory() For Linux, return a string
Download, rename and copy to purelibraries & test

Hope it works.. Just a quick lib I made..
Last edited by olejr on Mon Sep 13, 2004 6:32 pm, edited 1 time in total.
-
- PureBasic Expert
- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
What!?olejr wrote:Again..
If Someone is interested:
http://v3.homeip.net/getdir
GetCurrentDirectory() For Linux, return a string
Download, rename and copy to purelibraries & test![]()
Hope it works.. Just a quick lib I made..
User libs for Linux !?!?!? 8O
There are many problems with the current directory: In windows, the current directory is the directory of the file you loaded, for example if you doubleclick onto a .bmp and you have written a Bitmap-Editor associated with it, so your current directory will be the directory of the .bmp and not the directory of your executable!!
Ok, you say, let's determine the directory of the .exe - yeah, you will get the Compilers - Directory of your PureBasic installation. In my mind this is a bug, because the .exe should be compiled there where your source code is, because there would be the end-users .exe, but this should be soved by the Pure Basic team.
I think these Problems are just the same with Linux, so even if Linux supports some kind of 'Current Directory', I can't promise that you will get that string that you are really searchin for.
Ok, you say, let's determine the directory of the .exe - yeah, you will get the Compilers - Directory of your PureBasic installation. In my mind this is a bug, because the .exe should be compiled there where your source code is, because there would be the end-users .exe, but this should be soved by the Pure Basic team.
I think these Problems are just the same with Linux, so even if Linux supports some kind of 'Current Directory', I can't promise that you will get that string that you are really searchin for.
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
I'm understand what you say, but the question was:
How to get the directory where the executable was launched...
And the function in the library I created, return the path to the
launched exe, not the compiler.. That would be /usr/bin
anyway. If you followed the standard install....
Example: If your source is /home/blah/project/test.pb
And you compile this, my function return
/home/blah/project
How to get the directory where the executable was launched...
And the function in the library I created, return the path to the
launched exe, not the compiler.. That would be /usr/bin
anyway. If you followed the standard install....
Example: If your source is /home/blah/project/test.pb
And you compile this, my function return
/home/blah/project
Yeah and GetCurrentDirectory() too.I bet than SetCurrentDirectory() is needed too.

Also what about making a command take constants like this:
Code: Select all
String.s = GetDirectory(#PB_Current_Directory)
String.s = SetDirectory(#PB_Current_Directory)
String.s = GetDirectory(#PB_Temp_Directory)
String.s = GetDirectory(#PB_Home_Directory)
;etc...
-
- Enthusiast
- Posts: 252
- Joined: Fri Feb 20, 2004 5:43 pm
I like Kale's idea. It could be extended with #PB_Windows_Directory, #PB_ProgramFiles_Directory, #PB_TempFiles_Directory (as in the system temp files folder) and #PB_CurrentUser_Directory for windows and the equivalent directories for linux. Not really needed, it'd just make it quick and easy to get all the system folders.