Best File Storage Location in Linux?

Migrating a project to use Linux (the first time in 15 years!) and struggling with file locations. On Mac I use Application data, but in Windows the client wanted it at c:\theirproductfolder. Trying to determine the proper location to do this in Mint Linux.


I do what Xojo does and place mine in /opt/TOLIS_Group/Product. Or, /usr/local/ is another valid location. Both exist on all Linux / Unix platforms. Be aware that even though Linux’s handling of spaces in paths exists, many third party tools that may call your app don’t necessarily like them.

However, Since a Xojo app is built and expected to run next to the additional support folders, the application can be placed pretty much anywhere.

/usr/local/ always works. :slight_smile:

Here are guidelines:

The funny thing is that when we were trying to ratify the first LSB (Linux Standards Base) definitions, that location was supposed to have been “/usr/share/” or “/usr/local/share/”. I dropped out of the LSB project committee back in 2000 or so due to the constant bickering and basically getting NOTHING done for over 3 years of effort.

Thanks. So I’m on to the next thing (related). If I try to create a folder in /user/local/ (since this does not appear to be in the Special Folder class I’m doing it manually), I get an error code = 2 after I attempt to create a folder in that location.

[code] f = GetFolderItem("/usr/local/", Folderitem.PathTypeNative) //Exists
f = f.child(“companyname”)
if f.Exists = false then
f.CreateAsFolder //Called

if f.exists = false then
  dim iError as integer = f.LastErrorCode  //<-Error code 2 which means 'No such file or directory'
  return nil


Any clues on what I’m doing wrong?

Thinking out loud here. If I go into terminal I have to use sudo to use mkdir. How do I elevate my permissions to do this via the app?

Edit: the user I’m logged in as IS an Administrator.

Welcome to the light side of The Force™!

I normally put my files in a hidden folder off of the users home dir. Example: /home/{username}/.{MyAppName}

If you have a situation where multiple people share a single computer, this wouldn’t work however. Adjust accordingly.

[quote=215669:@Bob Keeney]Thinking out loud here. If I go into terminal I have to use sudo to use mkdir. How do I elevate my permissions to do this via the app?

Edit: the user I’m logged in as IS an Administrator.[/quote]

Even though you are logged in as an administrator, some things still need root privileges.

You may want to open a shell and create the folder there using sudo and then set permissions using chmod.

In Xojo, you can set the permissions on the folders using the Permissions property of the FolderItem class. I don’t know if you can update folders that are already existing that way or if it’s just folders you create.

Can’t just be an administrator - MUST be root.

The way I accomplish this is to instruct the user to run the app the first time from the command line using sudo if I see that the data folder is not present:

If Data Folder is absent
  Check if uid is 0 (root)
  if yes - 
    mkdir -p folder structure
    chmod folder structure
    quit to desktop so the app can be run as normal user
  if no -
    popup dialog instructing the user to run the app as root or with sudo this first time and quit

Hm…the light side of the force is mysterious and so far a pain in the behind. Naturally I’ll get more familiar with it over time but it’s painful today.