473,732 Members | 2,227 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 2680
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
1373
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
12576
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
2838
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
4512
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
2294
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
1470
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
3800
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
1668
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
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
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
9307
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...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
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.