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

R

Roel Schroeven

Steven D'Aprano schreef:
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
 
L

Laszlo Nagy

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
 
S

Steven D'Aprano

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").
 
R

Ross Ridge

Ross said:
However, the normal place to store settings on Windows is in the registry.

Lawrence D'Oliveiro said:
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

Lawrence D'Oliveiro

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.
 
R

Ross Ridge

Ross said:
As opposed to the file system being the single point failure?

Lawrence D'Oliveiro said:
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
 
G

Glenn Linderman

Eric said:
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.

file: URLs are not OS independent paths, but they are an OS independent
representation. Of course, it takes OS dependent code to transform OS
dependent paths to/from file: URLs.

But having the user define the roots, or having appropriate default
roots per platform, is a reasonable way to go. On the other hand, I'm
not sure you can or should define a "root" for "user files created by
this application", those files should go anywhere the user says. Of
course, it is then up to the user to find/specify them again, so you
shouldn't need to have a root for them, anyway.
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.

Sure, if that also comes along with not storing the application
directory under Program Files. Vista breaks programs that store
application data in application directories under Program Files. But
not if they are somewhere else. Be sure to handle the multi-user case,
if different users need different configurations, and don't have
different application directories.
 
L

Lawrence D'Oliveiro

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.
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.
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>
 
S

Steven D'Aprano

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.
 
J

Joe Strout

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
 
L

Lawrence D'Oliveiro

Steven D'Aprano said:
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.
 
P

Paul McNett

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top