473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What's the perfect (OS independent) way of storing filepaths ?

hello,

I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
I can think of something like:
- use a relative path if drive is identical to the application (I'm
still a Windows guy)
- use some kind of OS-dependent translation table if on another drive
- use ? if on a network drive

I'm interested what you all use for this kind of problem.
And I wonder why there isn't a standard solution / library in Python
available.

thanks,
Stef Mientki
Oct 19 '08 #1
35 1911
On Oct 19, 8:35*am, Stef Mientki <stef.mien...@gmail.comwrote:
I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
I don't think there is any such thing. What problem are you trying to
solve?
Oct 19 '08 #2
On Sun, 19 Oct 2008 14:35:01 +0200, Stef Mientki wrote:
hello,

I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
"Perfect"? I can't imagine any scheme which will work on every imaginable
OS, past present and future.

However, in practice I think there are two common forms still in use:
Posix paths, and Windows paths. I believe that OS/2 can deal with Windows
pathnames, and Mac OS X uses Posix paths (I think...). If you have to
support Classic Mac OS or other non-Posix systems, then your life will
become interesting and complicated.

And let's not even consider Unicode issues...

You might find this page useful:
http://en.wikipedia.org/wiki/Path_(computing)

Note that raw strings are for regular expressions, not Windows paths. Raw
strings can't end in a backslash, so you can't do this:

r'C:\My Documents\'

Instead, you can avoid having to escape backslashes by taking advantage
of the fact that Windows will accept forward slashes as well as
backslashes as path separators, and write 'C:/My Documents/' instead.

I assume you're familiar with the path-manipulation utilities in os.path?
>>import os
os.path.splitdrive('C://My Documents/My File.txt')
('C:\\\\', 'My Documents\\My File.txt')

I had to fake the above output because I'm not running Windows, so excuse
me if I got it wrong.

But honestly, I think your biggest problem isn't finding a platform-
independent way of storing paths, but simply translating between each
OS's conventions on where files should be stored.

In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these conventions!

--
Steven
Oct 19 '08 #3
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these conventions!
The first of those should do nicely for both Linux and Windows:
>>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'
Oct 19 '08 #4
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>>>import os
os.path.splitdrive('C://My Documents/My File.txt')
('C:\\\\', 'My Documents\\My File.txt')

I had to fake the above output because I'm not running Windows, so
excuse me if I got it wrong.
Not that it matters, but:
>>os.path.splitdrive('C://My Documents/My File.txt')
('C:', '//My Documents/My File.txt')
Oct 19 '08 #5
On 2008-10-19, Stef Mientki <st**********@gmail.comwrote:
I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
The question appears to me to be meaningless. File paths are
not OS independant, so an OS-independant way to store them
doesn't seem to be a useful thing to talk about.

--
Grant

Oct 19 '08 #6
>I (again) wonder what's the perfect way to store, OS-independent,
>filepaths ?
I'm in agreement that perfect probably isn't applicable. If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')
path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on the os.
Oct 19 '08 #7
Eric Wertman wrote:
>>I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?

I'm in agreement that perfect probably isn't applicable. If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')
path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on the os.
Eric, I like your idea.
It looks like a workable technique,
the user should initial define the roots once and everything works.
It should even work for network drives and websites.

Duncan, in windows it's begin to become less common to store settings in
Docs&Settings,
because these directories are destroyed by roaming profiles (a big
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the
application directory.

Drobinow, I want to distribute an application with a large number of
docs and examples.
Now for this application I can put everything in subpaths of the
main-application,
but you triggered me to put a warning in my code if I go outside the
application path.
Another application I've in mind, is a data manager (now written in Delpi),
in which I organize all my information: docs, websites, measurement data
etc.

Others, thank you for the ideas, you learende me some new os.path functions.

cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list
Oct 19 '08 #8
Duncan Booth wrote:
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these conventions!

The first of those should do nicely for both Linux and Windows:
>>>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'
A tuple of path elements, I would think.
>>a= ( 'c:', 'windows', 'system' )
a= ( '~', 'usr', 'bin' )
a= ( '..', 'src' )
You'll want a subclass too, which has a file for the last name, instead
of just folders.
>>a= ( 'c:', 'python', 'python.exe' )
If '..' and '~' aren't universally, recognized, you'll want special
flags.
>>DirUp= type( 'DirUp', (object,), { '__repr__': ( lambda self: 'DirUp' ) } )()
a= ( DirUp, 'src' )
a
(DirUp, 'src')

As for rendering them, 'win', 'unix', and 'mac' could be methods.
Oct 19 '08 #9
On Sun, 19 Oct 2008 15:40:32 +0000, Duncan Booth wrote:
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these conventions!

The first of those should do nicely for both Linux and Windows:
>>>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'

Except Windows users will be wondering why they have a directory starting
with '.' in their home directory. Dot to make files hidden is not AFAIK
supported by Windows.

--
Steven
Oct 19 '08 #10
On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:
Duncan, in windows it's begin to become less common to store settings in
Docs&Settings,
because these directories are destroyed by roaming profiles
Isn't *everything* destroyed by roaming profiles? *wink*

Seriously, I don't know anyone who has anything nice to say about roaming
profiles.

(a big
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the
application directory.
User config files in a global directory? That bites.

--
Steven
Oct 19 '08 #11
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
On Sun, 19 Oct 2008 15:40:32 +0000, Duncan Booth wrote:
>Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>>In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these
conventions!

The first of those should do nicely for both Linux and Windows:
>>>>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'


Except Windows users will be wondering why they have a directory
starting with '.' in their home directory. Dot to make files hidden is
not AFAIK supported by Windows.
The leading dot doesn't make the files hidden on Windows, but there's no
reason why you can't create files/folders with a leading dot and many
programs do just that. On the machine I'm on right now, 'dir .*' shows me:

Directory of C:\Documents and Settings\Duncan

18/10/2008 15:48 <DIR .
18/10/2008 15:48 <DIR ..
22/09/2008 20:28 45 .appcfg_nag
30/07/2004 09:28 244 .bashrc
18/01/2007 10:50 6,783 .bash_history
11/06/2006 12:30 <DIR .borland
06/04/2004 15:43 365 .emacs-places
11/03/2004 12:34 <DIR .emacs.d
08/01/2007 19:35 30,390 .fonts.cache-1
03/05/2008 18:07 <DIR .gimp-2.0
14/01/2005 14:34 <DIR .idlerc
11/06/2006 12:36 <DIR .jbuilder2005
27/06/2005 12:44 3 .leoID.txt
11/06/2006 12:43 <DIR .Nokia
11/06/2006 12:36 <DIR .primetime2005
11/06/2006 12:13 <DIR .qualitycentral
04/02/2004 12:24 <DIR .ssh
12/08/2004 14:30 <DIR .thumbnails
30/07/2004 14:11 49 .Xauthority
29/07/2004 16:25 12 .Xdefaults
29/07/2004 14:36 <DIR .xemacs
17/08/2006 09:19 2,869 .XWinrc

not to mention the thousands of .svn folders scattered across the rest of
the system.
Oct 20 '08 #12
On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:
Duncan, in windows it's begin to become less common to store settings in
Docs&Settings,
because these directories are destroyed by roaming profiles (a big
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the
application directory.
What do you do when users don't have write permission for the application
directory?
--
Steven
Oct 20 '08 #13
Stef Mientki wrote:
>Duncan, in windows it's begin to become less common to store settings in
Docs&Settings,
because these directories are destroyed by roaming profiles (a big
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the
application directory.
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>What do you do when users don't have write permission for the application
directory?
Use the application data directory (if you want it to roam), or the
local application data directory (if not). However, the normal place
to store settings on Windows is in the registry.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Oct 20 '08 #14
On Mon, 20 Oct 2008 10:20:06 +0000, Duncan Booth wrote:
Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>On Sun, 19 Oct 2008 15:40:32 +0000, Duncan Booth wrote:
>>Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:

In Linux, config files should go into:

~/.<appname>/ or /etc/<appname>/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these
conventions!

The first of those should do nicely for both Linux and Windows:

>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'


Except Windows users will be wondering why they have a directory
starting with '.' in their home directory. Dot to make files hidden is
not AFAIK supported by Windows.
The leading dot doesn't make the files hidden on Windows, but there's no
reason why you can't create files/folders with a leading dot and many
programs do just that. On the machine I'm on right now, 'dir .*' shows
me:
[snip]

And 75% [1] of average Windows users will either delete the file, move it
to a more convenient[2] location, or edit the file name to remove the dot.

I'm not saying you can't use files with a leading period under Windows.
You can name all your config files using Morse code if you want. I'm
saying it breaks the expected Windows file location guidelines, and it
displays a shameful lack of care by the programmer. Windows users are
more forgiving of badly behaved programs than Macintosh users, but even
so, it's pretty shoddy to ignore a platform's standard file locations.
Unix/Linux coders would rightly be annoyed if some tool created a
directory "/Program Files" instead of using the appropriate /bin
directory. This is no different.

[1] Based on my experience of the typical Windows user. YMMV.

[2] And they are right to do so. Programs that dump config files and
directories, hidden or not, in the top level of the user's home directory
are incredibly rude. It may have been a Unix standard for as long as
there has been a Unix, but it's still the programming equivalent of
coming into somebody's house and throwing your tools all over their
living room floor.

--
Steven
Oct 20 '08 #15
[2] And they are right to do so. Programs that dump config files and
directories, hidden or not, in the top level of the user's home directory
are incredibly rude. It may have been a Unix standard for as long as
there has been a Unix, but it's still the programming equivalent of
coming into somebody's house and throwing your tools all over their
living room floor.
Personally, I feel the same way about dumping files
into the python site-package directory ....

For example, I've never understood why kde and qt packages
don't use a sub-dir to house their xxxx.so libs ....

Moving the xxxx.egg-info files into sub-dirs or their own tree
would also clean up the site-packages dir ....
--
Stanley C. Kitching
Human Being
Phoenix, Arizona

Oct 20 '08 #16
Bruno Desthuilliers wrote:
Eric Wertman a écrit :
>>>I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?

I'm in agreement that perfect probably isn't applicable. If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')

make it "C:\"
wouldn't " C:/" be more universal and therefor better ?
>
>path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on
the os.

like, err, os.path.join ?
Yes (because these functions don't function correctly with i.e pdb,
which might be due to bugs in pdb).
cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list
Oct 20 '08 #17
On Mon, 20 Oct 2008 23:56:22 +0200, Stef Mientki wrote:
Bruno Desthuilliers wrote:
>Eric Wertman a écrit :
>>>>I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?

I'm in agreement that perfect probably isn't applicable. If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')

make it "C:\"
wouldn't " C:/" be more universal and therefor better ?

Do you really think there are Linux or Mac systems with a C: drive?

This whole question is based on the ludicrous assumption that general
file system paths can be platform-independent. That's a bit like trying
to write code that is programming language-independent.
--
Steven
Oct 20 '08 #18
Do you really think there are Linux or Mac systems with a C: drive?
>
This whole question is based on the ludicrous assumption that general
file system paths can be platform-independent. That's a bit like trying
to write code that is programming language-independent.

That's sort of where I was going originally... just pick a way to
store the path elements and write some simple functions (yes, many of
them will just be os.path calls) to reconstruct them based on the
actual needs of the application. If your root element is in
ascii.letters then it's most likely windows machine, so adding a ':'
and using os.path.join would be appropriate in the function.
Oct 20 '08 #19
In message <ma**************************************@python.o rg>, Stef
Mientki wrote:
I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
URLs beginning file://.
Oct 21 '08 #20
In message <gd**********@rumours.uwaterloo.ca>, Ross Ridge wrote:
However, the normal place to store settings on Windows is in the registry.
Which becomes a single point of failure for the whole system.
Oct 21 '08 #21
In message <01**********************@news.astraweb.com>, Steven D'Aprano
wrote:
Do you really think there are Linux or Mac systems with a C: drive?
And what about files on Dimdows systems kept on a drive other than C?
This whole question is based on the ludicrous assumption that general
file system paths can be platform-independent.
There is supposed to be a POSIX-compliant layer somewhere underneath all the
Dimdows crud. You could write to that.
Oct 21 '08 #22
In message <01**********************@news.astraweb.com>, Steven D'Aprano
wrote:
And 75% [1] of average Windows users will either delete the file, move it
to a more convenient[2] location, or edit the file name to remove the dot.
Doesn't seem very likely to me. Experienced Dimdows users would well know
that stuffing around with files they don't understand is liable to break
some application or another, so they shouldn't do it.
[2] And they are right to do so. Programs that dump config files and
directories, hidden or not, in the top level of the user's home directory
are incredibly rude. It may have been a Unix standard for as long as
there has been a Unix, but it's still the programming equivalent of
coming into somebody's house and throwing your tools all over their
living room floor.
Hmm, actually you have a point there. There's also the security issue, in
that other users can tell what apps you've been using based on the dotfiles
present in your home directory.
Oct 21 '08 #23
Steven D'Aprano schreef:
On Mon, 20 Oct 2008 10:20:06 +0000, Duncan Booth wrote:
>Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:
>>On Sun, 19 Oct 2008 15:40:32 +0000, Duncan Booth wrote:

Steven D'Aprano <st***@REMOVE-THIS-cybersource.com.auwrote:

In Linux, config files should go into:
>
~/.<appname>/ or /etc/<appname>/
>
In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.
>
There's no single string which can represent both of these
conventions!
The first of those should do nicely for both Linux and Windows:

>>os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'

Except Windows users will be wondering why they have a directory
starting with '.' in their home directory. Dot to make files hidden is
not AFAIK supported by Windows.
The leading dot doesn't make the files hidden on Windows, but there's no
reason why you can't create files/folders with a leading dot and many
programs do just that. On the machine I'm on right now, 'dir .*' shows
me:
[snip]

And 75% [1] of average Windows users will either delete the file, move it
to a more convenient[2] location, or edit the file name to remove the dot.
I don't think so: the average Windows user will never even see the files
in that directory; they only see the files in the 'Desktop' and 'My
Documents' folders.

--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov

Roel Schroeven
Oct 21 '08 #24
>However, the normal place to store settings on Windows is in the registry.

Which becomes a single point of failure for the whole system.
LOL :-)

BTW famous big popular programs like firefox and thunderbird will store
their configuration data under "Documents and Settings\Application
data". I believe this is the standard place to store application
configuration data. And inside that directory, you should be able to use
whatever file name you want, beginning with a dot or not.

Users who like to go inside "Documents and Settings\Application data"
and delete things without knowing what they do deserve to have a
malfunctioning system for sure.

BTW it would be nice to have a standard 'Application data" like
directory under UNIX. It is true that all kinds of programs will create
..app files in your home dir which is not very polite.

Laszlo

Oct 21 '08 #25
On Tue, 21 Oct 2008 11:32:14 +0200, Laszlo Nagy wrote:
Users who like to go inside "Documents and Settings\Application data"
and delete things without knowing what they do deserve to have a
malfunctioning system for sure.
The worst consequence from deleting a settings file should be to revert
to factory defaults (which, admittedly, may mean the software can't do
anything useful until you configure it). It should NEVER be malfunction
or data loss.

Of course, that's in principle. In practice, most software is
insufficiently defensive to work that way. In the Real World, deleting
settings files can have any consequence from nothing at all to serious
meltdown.

But as a matter of principle, users should be able to delete settings
files and lose nothing more than, well, settings. That's why it's a
SETTINGS file, not a DATA file. Settings should be information that can
be easily regenerated if lost. Anything that can't easily be regenerated,
like address books and bookmarks, are documents, not settings. Any
program which hides such documents in a hidden settings directory where
users can't easily make backup copies is a badly behaved program.

BTW it would be nice to have a standard 'Application data" like
directory under UNIX. It is true that all kinds of programs will create
.app files in your home dir which is not very polite.
Agreed, except I hope that when it eventually happens, the name won't
have a space in it, and it especially won't include the word "My" (as in
"My Settings", "My Preferences", or "My Application Data").
--
Steven
Oct 21 '08 #26
Ross Ridge wrote:
However, the normal place to store settings on Windows is in the registry.
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealandwrote:
Which becomes a single point of failure for the whole system.
As opposed to the file system being the single point failure?

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Oct 21 '08 #27
On 2008-10-21, Laszlo Nagy <ga*****@shopzeus.comwrote:
>
>>However, the normal place to store settings on Windows is in the registry.

Which becomes a single point of failure for the whole system.
LOL :-)

BTW famous big popular programs like firefox and thunderbird
will store their configuration data under "Documents and
Settings\Application data". I believe this is the standard
place to store application configuration data. And inside that
directory, you should be able to use whatever file name you
want, beginning with a dot or not.

Users who like to go inside "Documents and
Settings\Application data" and delete things without knowing
what they do deserve to have a malfunctioning system for sure.

BTW it would be nice to have a standard 'Application data"
like directory under UNIX.
The standard is to create either a .appname file or .appname
directory in the user's home directory.
It is true that all kinds of programs will create .app files
in your home dir which is not very polite.
It _is_ polite. Polite means following the established rules
and doing what's expected of you. That's exactly what is
expected of applications under Unix.

--
Grant Edwards grante Yow! I wonder if I ought
at to tell them about my
visi.com PREVIOUS LIFE as a COMPLETE
STRANGER?
Oct 21 '08 #28
In message <gd**********@rumours.uwaterloo.ca>, Ross Ridge wrote:
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealandwrote:
>Ross Ridge wrote:
>>However, the normal place to store settings on Windows is in the
registry.
>Which becomes a single point of failure for the whole system.

As opposed to the file system being the single point failure?
The file system is involved regardless. But leaving out an additional layer
of failure on top of it does make things more robust, yes. The file system
already has provisions for simultaneous access by multiple processes,
journalling, integrity checking etc; implementing a "registry" on top of
this means reinventing a whole separate API and architecture that has to
provide this sort of thing, or leave it out and suffer the well-known
consequences.

Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.
Oct 21 '08 #29
Ross Ridge wrote:
As opposed to the file system being the single point failure?
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealandwrote:
>The file system is involved regardless. But leaving out an additional
layer of failure on top of it does make things more robust, yes.
No, that doesn't follow. Having TCP as layer on top of IP doesn't make
the Internet less robust even though it's additional point of failure.
For the matter, settings files also have an additional layer of failure
in the code that intreprets and updates the setting files.
>The file system already has provisions for simultaneous access by multiple
processes, journalling, integrity checking etc; implementing a "registry"
on top of this means reinventing a whole separate API and architecture
that has to provide this sort of thing, or leave it out and suffer the
well-known consequences.
If settings files benefit from those provisions of the filesystem then
so does the registry. If the registry needs additional provisions so
do settings files for the same reasons.
>Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.
Nope. Microsoft implemented the registry because users were clobbering
things they weren't ment to, and it succeded in making it a less likely
occurence.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Oct 22 '08 #30
In message <gd**********@rumours.uwaterloo.ca>, Ross Ridge wrote:
Ross Ridge wrote:
>As opposed to the file system being the single point failure?

Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealandwrote:
>>The file system is involved regardless. But leaving out an additional
layer of failure on top of it does make things more robust, yes.

No, that doesn't follow. Having TCP as layer on top of IP doesn't make
the Internet less robust even though it's additional point of failure.
Which is a vacuous example.
For the matter, settings files also have an additional layer of failure
in the code that intreprets and updates the setting files.
See, it's clear you're too accustomed to the Windows mentality:
under "settings files" you're subsuming system config files, read-only
shared data, writeable data and per-user prefs--a whole bunch of things.
Recognize the distinction between these, and the fact that they need to be
kept distinct, and you can see how your assertions no longer hold up.
>>The file system already has provisions for simultaneous access by multiple
processes, journalling, integrity checking etc; implementing a "registry"
on top of this means reinventing a whole separate API and architecture
that has to provide this sort of thing, or leave it out and suffer the
well-known consequences.

If settings files benefit from those provisions of the filesystem then
so does the registry. If the registry needs additional provisions so
do settings files for the same reasons.
Quite different reasons, as I pointed out above.
>>Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.

Nope. Microsoft implemented the registry because users were clobbering
things they weren't ment to, and it succeded in making it a less likely
occurence.
<http://www.google.co.nz/search?q=registry+damage+prone>
Oct 22 '08 #31
On Tue, 21 Oct 2008 10:00:35 -0500, Grant Edwards wrote:
>It is true that all kinds of programs will create .app files in your
home dir which is not very polite.

It _is_ polite. Polite means following the established rules and doing
what's expected of you. That's exactly what is expected of applications
under Unix.
In medieval Russia, the Rus vikings (from whom modern Russia gets its
name) used to live in communal log huts. In the morning, a slave would
bring along a great big steaming bowl of water for the Rus to wash their
faces in. *One* bowl. The first person would wash his face, blow his nose
and spit in the bowl, then pass it on to the next person, who would
repeat all down the line.

This was the established social rules and everybody did what was expected
of them. It was also as rude as hell, and not just because "rude" also
means "unpolished, uncultured".

Putting preferences files in the user's top level directory is horribly
inconvenient for the user. It clutters their home directory. The old-time
Unix people recognised this, and made the files hidden so that their mess
wasn't visible. It certainly wasn't to protect the user from themselves,
because their users were other old-time Unix geeks who not only were
comfortable editing config files but expected to be able to. No, the only
reason for hiding the config files was because otherwise the user's home
directory would be too messy.

But of course all that means is that you avoid the mess so long as you
don't look at it. I have 125 dot files in my home directory. They include
"temporary" files from programs I haven't run in months, settings from
applications I haven't even heard of (where the hell did
".parallelrealities" come from?), log files, lock files and other dross
that has no place scattered across my home directory. Half of these files
contain important data which users will invariably miss when making
backups, and half of them are junk that don't need to be copied when
making backups (e.g. .thumbnails, .Trash), but there's no easy way to
include some while excluding others.

It may be expected, but it is still inconsiderate and just plain
*stupid*. A thirty year old stupidity is still a stupidity.

It would have been easy to avoid this: just copy the relevant bits of
the / directory hierarchy in the user's home directory. Global settings
go in /etc and per user settings go in ~/etc. Global temp files go into /
tmp and per user temp files go into ~/tmp. And so forth. Nice, neat and
perfectly easy to implement and easy to deal with.

--
Steven
Oct 23 '08 #32
On Oct 22, 2008, at 10:00 PM, Steven D'Aprano wrote:
It would have been easy to avoid this: just copy the relevant bits of
the / directory hierarchy in the user's home directory. Global
settings
go in /etc and per user settings go in ~/etc. Global temp files go
into /
tmp and per user temp files go into ~/tmp. And so forth. Nice, neat
and
perfectly easy to implement and easy to deal with.
I agree with you wholeheartedly on this one.

FYI, I think what you're looking for is a Mac. It's a Unix system,
and has /etc, but that's pretty much only there for compatibility with
other Unices -- well-behaved Mac apps put global settings (and so on)
in the appropriate subfolder under /Library, with per user data in the
appropriate subfolder under ~/Library.

Cheers,
- Joe

Oct 23 '08 #33
Stef Mientki <st**********@gmail.comwrites:
I (again) wonder what's the perfect way to store, OS-independent, filepaths ?
I can think of something like:
- use a relative path if drive is identical to the application (I'm still a
Windows guy)
- use some kind of OS-dependent translation table if on another drive
- use ? if on a network drive
There is no perfect solution, since file names and semantics differ from one
operating system to the next. Genera, the Lisp Machine operating system, has
facilities to abstract over the details of the file systems in use in the
1980s: Multics, ITS, TOPS-20, VMS, Unix, etc. Many of the concepts were
incorporated into the Common Lisp standard. Here are a couple of references:

http://gigamonkeys.com/book/files-an...html#filenames
http://www.lispworks.com/documentati...c/Body/19_.htm

The system described is not simple. Briefly, there's a machine-independent
way (logical pathnames) to specify file names that a program can use to
manipulate the files it knows about. There's no guarantee that you can access
an arbitrary file with these names. However, there's also the concept of a
machine-specific file namestring. Users can type in these machine-specific
namestrings, allowing the code to access arbitrary files.

Both types of pathnames can be manipulated via an API to derive other file
names. Here's how I create a pathname that refers to a subdirectory of my
home directory:

(merge-pathnames
(make-pathname :directory '(:relative ".sbcl" "systems"))
(user-homedir-pathname))

The code should work so long as the target file system supports
subdirectories, as Windows and Unix do.

bob
Oct 23 '08 #34
In message <01**********************@news.astraweb.com>, Steven D'Aprano
wrote:
Putting preferences files in the user's top level directory is horribly
inconvenient for the user.
There is a way around this: redefine the HOME environment variable to be the
directory where you want the dotfiles to end up.
Oct 24 '08 #35
Steven D'Aprano wrote:
On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:
>Duncan, in windows it's begin to become less common to store settings in
Docs&Settings,
because these directories are destroyed by roaming profiles
The directories aren't destroyed by roaming profiles. When the user logs
out, they get copied to the server. When they log in at a different
machine, they get copied to the workstation.

So configuration information saved in c:\Documents and
Settings\pmcnett\Application Data\My Application gets conveniently
migrated from machine to machine where I happen to login.

A really nice feature.

Isn't *everything* destroyed by roaming profiles? *wink*
I've heard such bashing of roaming profiles but I've never had anything
but love for them. That is, until people go and start saving their
movies and pictures in My Documents. Which is why I set their home
directory to a server share and have them save their docs there.

Seriously, I don't know anyone who has anything nice to say about roaming
profiles.
I loathe Windows, but roaming profiles was one thing they did (mostly)
right. I couldn't be happy in a world that didn't include roaming profiles.

Perhaps I'm not seeing the worst of it as I use Samba on Linux as the PDC?

Anyway, on Windows user configuration information should go in the
user's Application Data directory. If you don't want it to roam, you can
instead put it in the (hidden) Local Settings/Application Data directory.

Paul
Oct 24 '08 #36

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

Similar topics

1
by: Hari Shankar | last post by:
Dear all I have to develop a database independent application in c# 2003. It means the underlying database should be anything like ACCESS, Oracle or SQL and my application should not get affected...
3
by: Peter Hardy | last post by:
Hi guys, Sorry for the cross-post but I got no response in the asp.net newsgroup. I am trying to develop a mini e-learning application where the user provides content for each page....
1
by: Carly | last post by:
Hi, I work in Visual Basic .NET 2002 using ASP.NET. I am wondering what would be the best way to store/pass variables between pages. (Sessions are sooo simple to use but I hear they are not the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.