473,698 Members | 2,220 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
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
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
8608
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
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...
1
8898
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
7734
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...
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
3
2006
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.