Page 1 of 2
[Implemented] GetWorkingDirectory()
Posted: Thu Sep 09, 2004 9:23 am
by Num3
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

Posted: Thu Sep 09, 2004 11:57 am
by zikitrake
hope that this code helps you.
put it at the beginning of the program
Code: Select all
Global workdir$
workdir$=Space(255) : GetCurrentDirectory_(255,@workdir$)
...
(your code)
Posted: Thu Sep 09, 2004 12:11 pm
by olejr
zikitrake wrote:
Code: Select all
Global workdir$
workdir$=Space(255) : GetCurrentDirectory_(255,@workdir$)
...
(your code)
On
Linux??!?
Posted: Thu Sep 09, 2004 12:15 pm
by zikitrake
Posted: Thu Sep 09, 2004 12:20 pm
by olejr
Posted: Thu Sep 09, 2004 3:43 pm
by olejr
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..
Posted: Thu Sep 09, 2004 7:19 pm
by Num3
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..
What!?
User libs for Linux !?!?!? 8O
Posted: Thu Sep 09, 2004 9:26 pm
by olejr
Yes...
Have you tried it....?
It's my first 'test library'
And when I wrote rename,
that's incase it was downloaded as .txt.....
It would be nice to have the userlibraries folder
under purelibraries, so the 'root folder' could
stay clean.. Like Windows..
Posted: Sat Sep 11, 2004 12:10 pm
by Kazmirzak
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.
Posted: Sat Sep 11, 2004 12:23 pm
by olejr
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
Posted: Mon Sep 13, 2004 9:27 am
by Fred
Agreed, this function is needed, as long a GetHomeDirectory() which would returns 'Documents & setting\username\' on windows and '/usr/username' on linux & co. GetTemporaryDirectory() sounds useful too. If some other are needed, just tell. I bet than SetCurrentDirectory() is needed too.
Posted: Mon Sep 13, 2004 11:01 am
by Kale
I bet than SetCurrentDirectory() is needed too.
Yeah and GetCurrentDirectory() 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...
Posted: Mon Sep 13, 2004 11:11 am
by GreenGiant
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.
Posted: Mon Sep 13, 2004 11:41 am
by Fred
SetDirectory() would be only for the Current one then. Strange to have a generic command only for one purpose. I think I will stick to the 'portable' directory functions, as described above. Thank you for the suggestion tough !
Posted: Mon Sep 13, 2004 12:01 pm
by freak
The constant naming should be the other way around though, to stick to the PB constant naming
#PB_Directory_Home
#PB_Directory_Current