473,732 Members | 2,205 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
Steven D'Aprano wrote:
On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote:

> I wish the Linux Standard Base folks would specify that settings files
> should all go into a subdirectory like ~/settings rather than filling up
> the home directory with cruft. That was acceptable in the days when
> people
> only looked at their files with ls, but in these days of GUI file
> managers, it is ridiculous that there are more than 100 dot files and
> directories in my home directory.


Don't all file managers have an option to hide files beginning with '.'?

I don't want to hide them. I just don't want them in my face when I open
my home directory.


+1

This has been a gripe of mine on windows as well, and hiding files (or
extensions) is definitely not the answer.

Personally I think hidden files do more harm than good. It's not a
substitute for good file management, and it not an acceptable
alternative to good security either.

Cheers,
Ron

Sep 22 '05 #11
Tony Houghton wrote:

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.

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'

Cheers,
Ron

Sep 22 '05 #12
On Thu, 22 Sep 2005 02:14:57 +0000, Ron Adam wrote:
Don't all file managers have an option to hide files beginning with '.'?

I don't want to hide them. I just don't want them in my face when I open
my home directory.


+1

This has been a gripe of mine on windows as well, and hiding files (or
extensions) is definitely not the answer.

Personally I think hidden files do more harm than good. It's not a
substitute for good file management, and it not an acceptable
alternative to good security either.


Agreed. If "hidden files" are under the control of the user, then they
aren't really hidden, they are merely filtered from the current view.
Filtering may be useful in many circumstances, but if you are filtering
the same files all the time (eg "don't show me files starting with a
period" or "don't show me files with the invisible flag set") then you
should stick them in a subdirectory.

And if hidden files aren't under the control of the user (as certain
obscure ways of hiding files under Windows aren't), then it is a serious
security risk. You, the user might not be able to hide the files, but you
can bet some virus will. Eg if you drop an executable file in the Windows
XP font directory, it will not show up in the file explorer.
--
Steven.

Sep 22 '05 #13
Ron Adam wrote:
Tony Houghton wrote:

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.


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.

--
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 22 '05 #14
Ron Adam wrote:
Tony Houghton wrote:
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.


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'

Cheers,
Ron

Since you've gone to the trouble to use os.path functions why not use

file = os.path.join(pa rent, 'bombz')

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.pycon.org

Sep 22 '05 #15
rbt
On Tue, 2005-09-20 at 23:03 +0100, Tony Houghton wrote:
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?


~/.bombz works equally well on OSX.

Sep 22 '05 #16
rbt <rb*@athop1.ath .vt.edu> writes:
On Tue, 2005-09-20 at 23:03 +0100, Tony Houghton wrote:
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?


~/.bombz works equally well on OSX.


But Mac users - as opposed to Unix geeks - will expect to find it in
~/Library/Application Support/Bombz.

Us unix geeks can symlink that to ~/.bombz if we use the application
on both platforms.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 22 '05 #17
On Thu, 22 Sep 2005 00:23:56 +1000
Steven D'Aprano wrote:
I wish the Linux Standard Base folks would specify that settings files
should all go into a subdirectory like ~/settings rather than filling up
the home directory with cruft. That was acceptable in the days when people
only looked at their files with ls, but in these days of GUI file
managers, it is ridiculous that there are more than 100 dot files and
directories in my home directory.
So it is the very rationale why dot-files historically considered as
"hidden" in all unix shells and filemanagers.
<tilting at windmills>

Can I ask developers to break with the obsolete and annoying habit of
creating user-specific config files as ~/.app-name and use
~/settings/app-name instead?

</tilting at windmills>


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.

--
jk
Sep 22 '05 #18
Steve Holden wrote:
Ron Adam wrote:
Tony Houghton wrote:
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.

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'

Cheers,
Ron

Since you've gone to the trouble to use os.path functions why not use

file = os.path.join(pa rent, 'bombz')


It just didn't come to mind first. I don't use os.path that often.

Thanks. :-)

regards
Steve

Sep 22 '05 #19
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' )
Cheers,
Ron

Sep 22 '05 #20

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
8946
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
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
9181
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
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();...
1
3261
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
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.