Finding where to store application data portably

T

Tony Houghton

In <[email protected]>,
Ron Adam said:
Tony said:
This works on Win XP. Not sure if it will work on Linux.

import os

parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0]
file = parent + os.sep + '.bombz'

Ooh, no, I don't want saved data to go in the installation directory. In
general that practice encourages people to run with Admin access, and
it's about time Windows users were discouraged from that.

Yes, it occurred to me you didn't want to do that after I posted.

Looks like maybe the correct place would be as you suggested, but maybe
doing it this way would be better.

import os
user = os.path.join( os.environ["USERPROFILE"],
'Application Data',
'Bombz' )

I like that, it's nice and simple. It doesn't look like it's supported
on Win 9x though, but on 9x using the installation directory would be
acceptable.
 
S

Steven D'Aprano

There is an other way around: look at your home dir as if it is your
"settings" dir and don't clutter it with files other than application
config dot-files. Just make ~/files/, ~/bin/ ~/lib/ etc. for it.

Do you put everything into /etc (/etc/bin, /etc/var, /etc/usr, /etc/mnt,
and so forth)? If your home directory is for settings, why would you store
files and binaries inside your settings directory?

I understand the historical reasons for why ~/ is treated as a
structureless grab-bag of everything and anything. That made sense back in
the distant past when users used dumb terminals and they had perhaps half
a dozen dot files. But at the point your home directory has three times as
many dot files as regular files, the time has come to stop doing things
just because that's the way they have always been done.
 
R

Ron Adam

Steven said:
Do you put everything into /etc (/etc/bin, /etc/var, /etc/usr, /etc/mnt,
and so forth)? If your home directory is for settings, why would you store
files and binaries inside your settings directory?

I understand the historical reasons for why ~/ is treated as a
structureless grab-bag of everything and anything. That made sense back in
the distant past when users used dumb terminals and they had perhaps half
a dozen dot files. But at the point your home directory has three times as
many dot files as regular files, the time has come to stop doing things
just because that's the way they have always been done.

Yes, it's all pretty much historical isn't it. Someones needs to start
form scratch I think as far as file storage systems go.

Personally I'd love a cross platform intelligent file storage device
that managed security and user accounts independent of the operating
system. (With it's own internal CPU and firmware.)

A few thoughts ...

It should be built on concepts of 'Responsibility', 'Authority', and
'Delegation', So you could call it.. RADOS or RAD for short, or just
use my initials. RA.. (just kidding) ;-)

Also note that an application is just another user by proxy. And it all
comes down to private and shared user data. In other words, organize all
files by who's "Responsible" for them.

You would "Delegate Authority" by using file links with private keys in
them. Giving a file link to someone else wouldn't work since it would
need to be ran from your user account to be valid. These file links is
how you would access other files in other users file space.

Anyway... such a system would mean that when an application accesses the
Internet, (has Authority), to update it's own files, (Responsibility),
it does so in it's own user space and can't access any other users (or
applications) files. Virus's would find this very limiting.

Every user account would be a complete unit which can be backed up and
restored independently of the OS. If something went wrong you could
always find out which user (or application developer) was responsible.

Anyway... just wishful thinking. I'm sure there are a lot of problems
that would need to be worked out. ;-)

Cheers,
Ron Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,005
Latest member
ChasityFan

Latest Threads

Top