caudio/Headers/cUtils.h

24 lines
796 B
C
Raw Normal View History

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>
//! Grabs the current extention of a given string.
static std::string getExt(const std::string& filename)
{
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);
}
//! Prevents a bug with NULL passed into std::string.
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