Tue, 21 May 2013 14:24:10 +0300
added basename since windows doesn't have it
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/file.h | file | annotate | diff | comparison | revisions |
--- a/src/file.cpp Tue May 21 14:21:26 2013 +0300 +++ b/src/file.cpp Tue May 21 14:24:10 2013 +0300 @@ -124,6 +124,19 @@ } // ============================================================================= +str basename (str path) { + long lastpos; // FIXME: why doesn't str::last () work here? + for (lastpos = path.len () - 1; lastpos >= 0; --lastpos) + if (path[(size_t) lastpos] == DIRSLASH_CHAR) + break; + + if (lastpos < (log) path.len () - 1) + return path.substr (lastpos + 1, -1); + + return ""; +} + +// ============================================================================= FILE* openLDrawFile (str relpath, bool subdirs) { printf ("%s: Try to open %s\n", __func__, relpath.c ()); #ifndef WIN32