On Wed, Jan 27, 2016 at 02:14:17PM +0000, Philip Hazelden wrote:
> On Wed, Jan 27, 2016 at 1:43 PM Peter Pentchev <r...@ringlet.net> wrote:
> > On Wed, Jan 27, 2016 at 07:00:11AM -0600, Tom Browder wrote:
> > > Given so many handy methods for built-in classes, it would be nice to
> > have
> > > a couple of more for some, for instance:
> > >
> > > IO:Path.stemname
> > >   Like basename except any suffix is removed
> >
> > Hmm, this sounds like a nice idea on a first glance, but then again,
> > can you tell me exactly what situations would that be useful for?
> > Is it for compressed files (e.g. .zip vs .tar.gz) or MS-DOS/Windows
> > executables (.com, .exe, .bat), or something else?
> > When I strip filename extensions, I usually know exactly what extensions
> > I want to strip - e.g. ".conf" or ".pl" or something like that.  There
> > are very, very rare cases when any extension should be stripped - and
> > there's also a problem with that.
[snip my explanation of a problem with removing everything after the first dot]
> For a "convert files to $format" thing, you'd want to replace the
> extension. You don't need to specify the previous extension(s) if it's a
> quick-and-dirty thing where you know everything passed to it will be
> acceptable; and you don't want to, if you're passing out to some other
> service which can handle various input formats. (e.g. a wrapper around
> ffmpeg or ImageMagick or something - they can handle a lot of filetypes
> with a lot of likely extensions.)

Right, so that would probably mean that you need a function that removes
the *last* extension; that might indeed make sense, although it's
trivial to implement as a regular expression substitution (but also beware
the case of a filename with no dots at all).


Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to