std.path.getName(): Screwy by design?

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 1 01:43:28 PST 2011


On Tuesday 01 March 2011 01:31:52 Nick Sabalausky wrote:
> "Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
> news:mailman.2076.1298971012.4748.digitalmars-d at puremagic.com...
> 
> > I think that I agree with you on all counts. I can understand if the path
> > stuff
> > can't deal with / or \ in file names (that's probably not worth trying to
> > get to
> > work right), but it _should_ be able to handle directories with dots in
> > them and
> > files with no extension. Files without extension may be uncommon in
> > Windows, but
> > they're common enough on Linux.
> 
> Due to the practical need for dealing with Unixy systems (for instance, an
> external web server) and cross-OS compatibility, etc, I deal with
> extension-less files (and filenames that start with a dot) quite frequently
> even on Windows, and even though I'm primarily a Windows user.
> 
> That reminds me of something I've often wondered, though: Does unix
> consider a file named ".bashrc" to be a nameless file with an extension of
> "bashrc", or just an extentionless file named ".bashrc"? (I know unix
> doesn't typically have a concept of file extension, it's all just part of
> the name, but unix programs will often care about the extension portion of
> a filename.)

If a program were trying to treat .bashrc like it had an extension, I would 
expect it to be treated as a file with no name and bashrc as its extension. I 
don't think that anything else mould make sense. However, it's a prime example 
of a situation where extensions make no sense. In general, Linux isn't big on 
extensions. The DEs generally use MIME types to determine the type of a file 
rather than its extension, and most programs follow suit. But in the rare case 
where a program would care about extensions, I would expect it to be looking for 
_specific_ extensions (like mp3 or flac or pdf or whatever), so it wouldn't be 
looking for a .bashrc file and it wouldn't really matter if it treated its 
extension as bashrc.

- Jonathan M Davis


More information about the Digitalmars-d mailing list