Proper Directory for saving data files.

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Proper Directory for saving data files.

Post by Diverod » Tuesday 07th 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.

BruceSteers
Posts: 766
Joined: Thursday 23rd July 2020 5:20pm

Re: Proper Directory for saving data files.

Post by BruceSteers » Tuesday 07th December 2021 3:19am

Diverod wrote:
Tuesday 07th 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

cage
Posts: 104
Joined: Monday 02nd September 2019 5:47am
Location: Phoenix Arizona

Re: Proper Directory for saving data files.

Post by cage » Tuesday 07th December 2021 8:14am

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..

Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Proper Directory for saving data files.

Post by Diverod » Tuesday 07th December 2021 3:18pm

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.

User avatar
thatbruce
Posts: 26
Joined: Saturday 04th September 2021 11:29pm

Re: Proper Directory for saving data files.

Post by thatbruce » Tuesday 07th December 2021 4:07pm

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

Post Reply