473,698 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding where to store application data portably


I'm using pygame to write a game called Bombz which needs to save some
data in a directory associated with it. In Unix/Linux I'd probably use
"~/.bombz", in Windows something like
"C:\Documen ts And Settings\<user> \Applicacation Data\Bombz".

There are plenty of messages in the archives for this group about how to
find the correct location in Windows, but what about Mac OS? There I
don't know the correct location for this sort of thing at all. And there
are other, more obscure systems like RISC OS (it may not have pygame but
it definitely has python). Surely this is something that's crying out
for an official function in os or sys.

--
The address in the Reply-To is genuine and should not be edited.
See <http://www.realh.co.uk/contact.html> for more reliable contact
addresses.
Sep 20 '05
22 2673
In <iA************ ********@tornad o.tampabay.rr.c om>,
Ron Adam <rr*@ronadam.co m> wrote:
Tony Houghton wrote:
> This works on Win XP. Not sure if it will work on Linux.
>
> import os
>
> parent = os.path.split(o s.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["USERPROFIL E"],
'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.

--
The address in the Reply-To is genuine and should not be edited.
See <http://www.realh.co.uk/contact.html> for more reliable contact addresses.
Sep 23 '05 #21
On Thu, 22 Sep 2005 19:09:28 +0400, en.karpachov wrote:
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.

--
Steven.

Sep 23 '05 #22
Steven D'Aprano wrote:
On Thu, 22 Sep 2005 19:09:28 +0400, en.karpachov wrote:

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.


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 "Responsibl e" 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
Sep 23 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1372
by: jeff elkins | last post by:
I'm creating an app that relies on a configuration file at launch. The file will always exist in the app's installation directory, but I have no control over where that might be. Is there an OS-independent way that I can instruct the app to look in it's home directory for startup files? Right now, I'm hard coding the path, which won't work. Thanks,
2
12574
by: Peter Rilling | last post by:
How does Windows store passwords that it uses? For instance, when you install a service, you can provide it the username and password. This information is stored somehow so that at a later date the service can start without interaction from the user. Also for COM+ components. This is what I want to be able to do. I want the ability to store passwords in a protected manor so that my .NET application can start a secure process at a...
1
2834
by: pei_world | last post by:
hi I am new to C# programming. can anyone tell me what is the standard way to store high sensitive user data for application, so that application next run can get back those data.
5
4508
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and password would be different than the one the user enters for ASP.NET forms authentication. The ID/password in question is used by the application, itself, for accessing the SQL Server. Thanks in advance.
2
2293
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even throws and error about a DataReader connection being already open even though I only use Data Sets in my code. Please take a look and see if you can find my leak because I'm going nuts here and am losing hope... I keep blaming the server and the...
4
1466
by: UJ | last post by:
I have a need to know what the domain name is when I'm running a site. Essentially the problem I have is that I let the user build a web page and then I display it using a IFRAME. But the IFRAME wants the entire path, not just relative. So I need to build entire URL. I can store it in a database but the problem then becomes people running SSL vs. not SSL so I'll need to do some manipulation. Anybody got any suggestions? TIA - Jeffrey.
1
3798
by: Rico | last post by:
Hello, I have an ole object field (Access XP/2002) which I store images in. I have a couple of questions regarding this; is it possible to determine the image dimensions? Secondly, is there any way to determine what application is associated with the stored OLE Object and is there a way to associate that object programmatically with another application? Thanks!
6
1663
by: Tom E H | last post by:
My Python application includes some data files that need to be accessed by modules I distribute with it. Where can I put them, and how should I arrange my code, so that it works across platforms? On Linux, I could install the data to "/usr/lib/myprogram/datafile", and on Windows to "datafile" relative to where the executable (made by py2exe) is installed. Then I could detect the operating system, and choose appropriately.
0
230
by: Brian Vanderburg II | last post by:
Lance Gamet wrote: Lance Gamet wrote: One way I've just started to use it to create a utility function to return the location of the user data folder, depending on the operating system: import os, sys def GetUserDataDirectory(): dir = None
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.