Page 1 of 1

Proper Directory for saving data files.

Posted: Tuesday 7th December 2021 2:47am
by Diverod
I tried searching for something here but it said my words were to common, so it ignored them. :(

Being new to Linux/Ubuntu I wanted to ask if there is a preferred directory for saving data files from an application?
Thanks, RodG.

Re: Proper Directory for saving data files.

Posted: Tuesday 7th December 2021 3:19am
by BruceSteers
Diverod wrote: Tuesday 7th December 2021 2:47am I tried searching for something here but it said my words were to common, so it ignored them. :(

Being new to Linux/Ubuntu I wanted to ask if there is a preferred directory for saving data files from an application?
Thanks, RodG.
you'll want the .config dir in your home directory i should think, use a folder in there with the same name as your application...
User.Home &/ ".config" &/ Application.Name

Re: Proper Directory for saving data files.

Posted: Tuesday 7th December 2021 8:14am
by cage
You can also save the data file in the same directory as your program.
Application.path &/ Application name
Or you can save it to a dedicate folder like Bruce suggested.
Myself I tend to save my data files in the folder as my program..

Re: Proper Directory for saving data files.

Posted: Tuesday 7th December 2021 3:18pm
by Diverod
Thanks, didn't want to head down a road that could turn bumpy later.
I can see where each of these could be a preferred method over the other depending on the type of data being saved.

Re: Proper Directory for saving data files.

Posted: Tuesday 7th December 2021 4:07pm
by thatbruce
Consider the scope of your data.
If it is ephemeral, i.e. pertinent only to an instance of your project, then store it using the Gambas Temp mechanism.
If it is pertinent to the user running the project then store it somewhere in "~". As Big B Bruce says you can use the .config/gambas3 dir but I generally shy away from that for purity reasons.
If it is pertinent only to the project you MAY store it in the project directory. However, you MUST understand relative pathing if you do that, otherwise you will get totally confused later. Also you must understand the Gambas project directory structure.
If it is system wide, then store it in a shareable directory, for example /srv.

The only data I store in the project directory is project metadata and then only after considerable thinking about what data might go in there at a later date.

I have spoken.
b