![]() |
Location for storing data: /home/user/appname?
OK, I feel a bit silly for not realizing this a *lot* earlier during development of my latest app -- but it occurs to me that the reason that it has so much trouble doing a file 'save' is that the 'user' account has very little 'write' access -- except (mostly) to '/home/user'.
I had intended to allow the user to save to the directory containing my actual app (i.e. /usr/lib/appname) -- but my program (and any others that attempt to do the same thing?) silently fail when a 'save' is attempted to a directory like that -- presumably since only 'root' has write access to most of the file system. So...is the 'official' spot for apps to save data supposed to be '/home/user'? Or, to keep data separate, '/home/user/appname'? I suppose that the user then has the ability to make this a logical link to, say, one of the '/media' (card) locations? If so, then there is not much point is writing an app that lets the person navigate all over the file system for files to read/write -- and should instead 'hardcode' this to '/home/user/appname'? Thanks for any feedback! My silly app is stalled out due to this issue :( |
Re: Location for storing data: /home/user/appname?
I think "/home/username/.appname" is common for user-specific app settings and files on Linux systems. Note the period. It makes it a hidden folder, so it won't take up space in regular directory listings.
Also, when/if your app requires a lot of storage space, I think it's a good idea to let/require the user to pick a place to store the files. But I'd probably still keep small setting files under "/home/username/.appname". |
Re: Location for storing data: /home/user/appname?
I would add that isn't a good idea hardcode the "/home/user" path, because while Maemo only has "user", for example in Mer you create the username with the name you want. So, for compability with Mer is a good idea detect the user who is using the application.
Example code in python: Code:
import os |
Re: Location for storing data: /home/user/appname?
Thanks to both of you (and future others) responding to my query :)
It occurred to me that when I wrote 'Mephemeris', that I made sure that '/usr/lib/mephemeris' had done a 'chmod 777' on the directory, to insure that the 'user' had full access to write files there (for the downloaded image pics, which overwrote each other so as not to accumulate). I guess I am still wondering if this is 'wrong' in the Maemo world or not? Perhaps it is 'common' in the Linux world to write to '/home/user/.appname', but I notice that on *my* N800, there is almost nothing there at all. As well, in Python, I am wondering what the heck advantage there is to using the 'hildon.FileChooserDialog' instead of the normal 'gtk.FileChooserDialog'. For example, so far I have not found evidence that it looks nicer, or obeys 'filtering' rules that I give it, and also (I think) ignoring my 'set_current_directory' command -- so why is it so strongly encouraged? This all plays into my question of providing the user with a good GUI for finding/writing files on Maemo. |
Re: Location for storing data: /home/user/appname?
Quote:
Keep in mind that content of /tmp will be lost after a reboot. See also http://tldp.org/LDP/Linux-Filesystem...tml/index.html I don't know how much this is applicable in Maemo. |
Re: Location for storing data: /home/user/appname?
Changing anything under /usr to be writeable by a mere user is "wrong" :)
As explained above, temporary files should go in /tmp and any user files should go somewhere under the user's home directory (~/) |
Re: Location for storing data: /home/user/appname?
Quote:
Or do you intend to also change your app to 'create' the necessary '.appname' subdirectory if it doesn't exist? |
Re: Location for storing data: /home/user/appname?
Quote:
Code:
if not os.path.exists(path_here): That may not be the best way, but it works. |
Re: Location for storing data: /home/user/appname?
Quote:
Code:
if not os.path.exists("~/.appname"): |
All times are GMT. The time now is 14:09. |
vBulletin® Version 3.8.8