rlm@1: // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. rlm@1: // Copyright (C) 1999-2003 Forgotten rlm@1: // Copyright (C) 2004 Forgotten and the VBA development team rlm@1: rlm@1: // This program is free software; you can redistribute it and/or modify rlm@1: // it under the terms of the GNU General Public License as published by rlm@1: // the Free Software Foundation; either version 2, or(at your option) rlm@1: // any later version. rlm@1: // rlm@1: // This program is distributed in the hope that it will be useful, rlm@1: // but WITHOUT ANY WARRANTY; without even the implied warranty of rlm@1: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the rlm@1: // GNU General Public License for more details. rlm@1: // rlm@1: // You should have received a copy of the GNU General Public License rlm@1: // along with this program; if not, write to the Free Software Foundation, rlm@1: // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. rlm@1: rlm@1: #include "tools.h" rlm@1: rlm@1: namespace VBA rlm@1: { rlm@1: rlm@1: std::string sCutSuffix(const std::string & _rsString, rlm@1: const std::string & _rsSep) rlm@1: { rlm@1: return _rsString.substr(0, _rsString.find_last_of(_rsSep)); rlm@1: } rlm@1: rlm@1: Glib::ustring sCutSuffix(const Glib::ustring & _rsString, rlm@1: const Glib::ustring & _rsSep) rlm@1: { rlm@1: return _rsString.substr(0, _rsString.find_last_of(_rsSep)); rlm@1: } rlm@1: rlm@1: bool bHasSuffix(const Glib::ustring & _rsString, rlm@1: const Glib::ustring & _rsSuffix, rlm@1: bool _bCaseSensitive) rlm@1: { rlm@1: if (_rsSuffix.size() > _rsString.size()) rlm@1: { rlm@1: return false; rlm@1: } rlm@1: rlm@1: Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size()); rlm@1: rlm@1: if (_bCaseSensitive) rlm@1: { rlm@1: if (_rsSuffix == sEnd) rlm@1: { rlm@1: return true; rlm@1: } rlm@1: } rlm@1: else rlm@1: { rlm@1: if (_rsSuffix.lowercase() == sEnd.lowercase()) rlm@1: { rlm@1: return true; rlm@1: } rlm@1: } rlm@1: rlm@1: return false; rlm@1: } rlm@1: rlm@1: } // namespace VBA