|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2008-05-25 01:11:03
on Thu May 22 2008, "Johan Nilsson" <r.johan.nilsson-AT-gmail.com> wrote:
> Vladimir Prus wrote:
>> Frank Mori Hess wrote:
>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>
> [snip]
>
>>
>> Unless you want 'leaf' to be named 'basename'. See, we already have
>> 'basename', which unfortunately does something different.
>
> [sorry for jumping in]
>
> I personally have no problems with leaf, but just for comparison, the
> following is from Ruby (note that extension can be conditionally removed):
>
>>ri File.basename
> --------------------------------------------------------- File::basename
> File.basename(file_name [, suffix] ) -> base_name
> ------------------------------------------------------------------------
> Returns the last component of the filename given in _file_name_,
> which must be formed using forward slashes (``+/+'') regardless of
> the separator used on the local file system. If _suffix_ is given
> and present at the end of _file_name_, it is removed.
>
> File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
> File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
Which exactly mirrors the posix command-line function. On every POSIX
system
$ basename foo/bar/baz.x
baz.x
$ basename foo/bar/baz.x .cpp
baz.x
$ basename foo/bar/baz.x .x
baz
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk