2010-02-09 05:18:39 +01:00
|
|
|
// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
|
|
|
|
// This file is part of the "cAudio Engine"
|
|
|
|
// For conditions of distribution and use, see copyright notice in cAudio.h
|
|
|
|
|
2009-06-21 05:24:30 +02:00
|
|
|
#ifndef CUTILS_H_INCLUDED
|
|
|
|
#define CUTILS_H_INCLUDED
|
|
|
|
#include <string>
|
|
|
|
|
2009-11-21 01:39:46 +01:00
|
|
|
//! Grabs the current extention of a given string.
|
2009-11-20 04:39:56 +01:00
|
|
|
static std::string getExt(const std::string& filename)
|
2009-08-08 07:51:32 +02:00
|
|
|
{
|
2009-06-21 05:24:30 +02:00
|
|
|
if(filename.find_last_of(".") == std::string::npos) return filename;
|
|
|
|
return filename.substr(filename.find_last_of(".") + 1, filename.length()-filename.find_last_of(".")-1);
|
|
|
|
}
|
|
|
|
|
2009-11-21 01:39:46 +01:00
|
|
|
//! Prevents a bug with NULL passed into std::string.
|
2009-11-20 04:39:56 +01:00
|
|
|
static std::string safeCStr(const char* str)
|
|
|
|
{
|
|
|
|
if( str != NULL ) return std::string(str);
|
|
|
|
else return std::string("");
|
|
|
|
}
|
|
|
|
|
2009-06-21 05:24:30 +02:00
|
|
|
#endif //! CUTILS_H_INCLUDED
|