Re: How to get filename from path in C++
Andreas Dehmel wrote:
On Tue, 21 Jul 2009 15:55:39 +0200, Bo Persson wrote:
tni wrote:
James Kanze wrote:
On Jul 21, 12:09 pm, tni <nob...@example.com> wrote:
Fred Zwarts wrote:
"Aaron Gray" <ang.use...@gmail.com> wrote in
messagenews:7ckkbaF25sqm3U1@mid.individual.net...
Whats the best way to get the filename from a path using
std::string and using char[] ?
This is not really a C++ question.
It should be.
Maybe, but how? To date, I don't think anyone has proposed
anything. (Remember, a standard solution would have to work
when the system didn't have sub-directories, or when it also had
version numbers and such.)
It doesn't have to work everywhere.
But it is a rather bad standard, if it is not implementable on some
systems. The C and C++ standards go to great lengths not to require
specific pointer formats, 32 bit ints, or IEEE floating point,
because it is known that important systems out there can't support
it.
You seem to suggest that by leaving lots of fundamental concepts
implementation-defined the standard becomes more usable or
something.
Yes, by not specifying everything down to the last bit, the language
is actually usable on a wider range of machines.
Another "totally portable" language needs special hardware add-ons to
run on some machines where C++ runs natively:
http://www-03.ibm.com/systems/z/advantages/zaap/index.html
I'd say that, on the contrary, the only result of this
is that rather than parts of it being unusable on some exotic
systems it becomes unusable everywhere. What good is a standard
which doesn't even allow me to do the most elementary things like a
simple portable command line tool which takes a filename as
parameter and does some IO-operation with that file?
What makes you think that you run command lines on all systems? Not
everything is a desktop.
It would be really surprising if the language would then try to
standardize file names and directories.
Me too, but only because so far the standard seems to have a history
of trying to weasel out of exactly the kind of ugly, low-level
abstractions a standard library should provide first and foremost
of all. Which pretty much forces developers to code outside of the
standard, e.g. using Qt, which (although primarily a GUI-abstraction
layer) does provide things like a _proper_ string class (efficient,
with fully-fledged interfaces to codecs, filesystem etc). In other
words exactly the kind of thing that's indispensable for a _usable_
standard library.
Yes, Qt claims "Portability across desktop and embedded systems". What
about everyting else?
This system doesn't even have a GUI:
http://www-03.ibm.com/systems/z/hardware/
We'll see about C++0x. Personally, based on past experience, I'm not
holding my breath...
Please don't.
Bo Persson