Re: Path manipulation in glib.h



On Wed, 28 Oct 1998, Tor Lillqvist wrote:

> > I'd opt for a set of path manipulation functions in glib.h (in addition
> > to g_basename() and g_dirname():
> 
> Good idea. There is also g_path_is_absolute() and g_path_skip_root()
> now, but something even more generic would be a Good Thing. Especially
> if we want to support VMS, which usess different separators between
> directory levels and beetween the directory path and the basename.
> 
> Of course, going through all code and change it to use the generic
> functions, instead of assuming that the directory separator is a
> single fixed character, etc, will take some time...
> 
> > 	C:\WinNT\Fonts\Arial.ttf -> { "", "C", "WinNT", "Fonts", "Arial.ttf", NULL }
> 
> Hmm, what's the semantics of the empty first element in the array? And
> how should one distinguish between X:\foo\bar.zap and X:foo\bar.zap,
> where X isn't the current drive?

With a scrying sphere? It'd probably be more successful then trying to
encapsulate all of the DOS weirdness. (I should know -- I once tried to
compile an "algrebra of path names". I'm better now, thank you.)

If you're into DOS stuff, don't forget UNC paths
("\\SERVER-NAME\MOUNT\DIR\FILE"). 

> Yes, the concept of per-drive current directories has to be one of the
> most brain-damaged things in the DOS/Windows world. But, uh, if we
> really want to support Windows, I guess it should be taken into
> consideration... Are there other similarly strange semantics in VMS
> for instance? MacOS has a single-rooted file system, hasn't it?

VMS is different in some subtle ways, mostly because it uses things that
might be called environment variables to keep track of mounts and current
directories (or at least that is my impression of it.) And the syntax is
_completely_ different from UNIX or the Mac. ("[SYS$ETC]a.b.c" seems to
feel right.) 

I'm better qualified to comment on the MacOS, and it too is a bit unusual.
Some examples (I hope I'm getting these right):

  root                            = <nothing, cannot be referred to>
  The root of a particular disk   = disk-label
  A file on a disk                = disk-label:folder:subfolder:file
  A file in the current directory = file
  A file in a subfolder of the current directory = subfolder:file
  A file in the parent of the current directory  = ::anotherfile

(Hmm, I can't recall what, if anything, ":foo:bar" means.) 

The doubling of the directory separator has the same meaning as ".." in
UNIX derivatives (which is fairly ingenious, IMO, as few people really
need "//" to mean the same as "/".) I can't think, off hand, of any way to
refer to the root of the disk that the current directory is on, without
using the disk's label. And disks are named by label, not by order,
physical position, or mount name. 

Also, realize that most users will never see any of this, and that only a
few programs (mostly developers tools, natch) show complex paths in text
form, and some of these path styles (like :::) may in fact be part of
specific tools and not part of the OS. I'm not clear on that.

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]