Forum > Operating Systems

Portable apps on Unix/Linux

(1/2) > >>

Hi all,

It's fairly easy to write a portable application for Windows, e.g.:

* avoid the registry
* read config files from the current/application directory
* put all required dlls in the application directory
On Linux/OSX/FreeBSD, things are different. Suppose I'd want to write a portable password vault with an SQLite database that you can use on a USB stick.

I suspect I'd have to statically link my libraries or use FPC's LoadLibrary to load in the .so's - but where do I store them, which brings me to my next question:

File locations
Determining the directory an application is in is not completely reliable (see other messages/cross-platform wiki), so reading config files from the app directory wouldn't really work.
As far as I understand, using resources is a Windows thing.
For config files etc, I could just write out a config file into the user's directory, but I'd prefer if I could keep it on the USB key  :D

What solutions or thoughts do you have?


if you have few settings to save, why not use an encryption on a plain text file. (.ini ? lol)
or a XMLPropStorage (i use that a lot).

Hi FabienWang,

Yeah, but where to put them? Ideally I'd put them in the directory where the application is running but that apparently isn't reliable.
I could of course just ignore that and use Application.Exename/Paramstr[0]/whatever it's called, like everybody else...

Modified: RTFM (at least partly): FreePascal Programmer's Guide chapter 13, resources: "all FPC supported platforms now have resources available". So that's one question solved  :)

What I do with configs is accept a command line param with the location the user wants to use for the config.  If param is not passed, the user's home directory is used.  In this way I do not need to worry about mount points and if the user wants it portable, the user can decide where to store the config.  It also allows multiple configs for multiple users even using the same USB stick.

Good one. I'll keep that in mind.


[0] Message Index

[#] Next page

Go to full version