qse/qse/lib/cmn/path-basename.c

49 lines
1.3 KiB
C
Raw Normal View History

/*
2012-08-16 03:47:55 +00:00
* $Id$
*
2013-12-31 10:24:12 +00:00
Copyright 2006-2014 Chung, Hyung-Hwan.
2009-09-16 04:01:02 +00:00
This file is part of QSE.
2009-09-16 04:01:02 +00:00
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
2009-09-16 04:01:02 +00:00
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
2009-09-16 04:01:02 +00:00
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
2011-10-14 22:57:41 +00:00
#include <qse/cmn/path.h>
#define IS_MSEP(c) QSE_ISPATHMBSEP(c)
#define IS_WSEP(c) QSE_ISPATHWCSEP(c)
const qse_mchar_t* qse_mbsbasename (const qse_mchar_t* path)
{
const qse_mchar_t* p, * last = QSE_NULL;
for (p = path; *p != QSE_MT('\0'); p++)
{
if (IS_MSEP(*p)) last = p;
}
return (last == QSE_NULL)? path: (last + 1);
}
const qse_wchar_t* qse_wcsbasename (const qse_wchar_t* path)
{
const qse_wchar_t* p, * last = QSE_NULL;
for (p = path; *p != QSE_WT('\0'); p++)
{
if (IS_WSEP(*p)) last = p;
}
return (last == QSE_NULL)? path: (last + 1);
}