Portable Linux app with TIniPropStorage lazarus / 7-LCL ---------------------------------------------------------------------- Leledumbo · 2009-02-17 05:38 I've built app with TIniPropStorage to store its configuration. Under Windows, the .ini file is created in the directory of the application, so this is good for portable apps. However, under Linux the file is created in the home directory. How can I make it portable? Let's assume that the user has write permission since portable apps are usually put in flash drives (I can simply write a note about that). ---------------------------------------------------------------------- arnoldb · 2009-02-17 08:20 How about: Code: [Select]var s:string; begin {$IFDEF LINUX}   s:=extractfilepath(application.ExeName);   s:=s+'myapp.ini';   IniPropStorage1.IniFileName:=s; {$ENDIF} end; ---------------------------------------------------------------------- Leledumbo · 2009-02-18 03:41 According to the wiki, it's equivalent to ParamStr(0) and is the wrong way on Unix to retrieve application directory. However, since I'm assuming that it's put in a flash drive and the user run it directly from there, your solution might work. I'll put a big README in the archive, thanks. ---------------------------------------------------------------------- arnoldb · 2009-02-18 08:07 True - I didn't check that on the Linux/Unix side.  I had a look at the link you posted, but unfortunately there seems no other way to handle it; the other "default" directories on Linux is nowhere close to doing something like this... So for now, this would appear to be the best way to handle removable media, unless somebody else has a more elegant idea. ---------------------------------------------------------------------- Bad Sector · 2009-03-01 00:11 Sure. Use getpid to obtain the current program's PID, then use readlink to figure the target of /proc//exe which is a symbolic link to your executable. Strip the executable filename and there you have the path :-). This method is used by many linux programs and its around for some years now so i believe its quite stable. ---------------------------------------------------------------------- arnoldb · 2009-03-01 15:05 Thanks for that info BadSector    I'll definitely be checking this out; it might be worthwhile having a standard function in FPC to do this... ---------------------------------------------------------------------- Bart · 2009-03-01 22:30 Quote from: BadSector on March 01, 2009, 01:11:01 amSure. Use getpid to obtain the current program's PID, then use readlink to figure the target of /proc//exe which is a symbolic link to your executable. Strip the executable filename and there you have the path :-). This method is used by many linux programs and its around for some years now so i believe its quite stable.But does it also work if I have a (hard)link to the executable and run the link, especially if the hardlink is in another directory (since that is what you want to retrieve)? Code: [Select]simenon:~$ ln path-to/someprog ./link simenon:~$ ./link Bart