Commit 80851522 authored by cutealien's avatar cutealien

Add function mergeFilename


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4680 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0b58a6d5
...@@ -137,7 +137,7 @@ inline s32 isInSameDirectory ( const io::path& path, const io::path& file ) ...@@ -137,7 +137,7 @@ inline s32 isInSameDirectory ( const io::path& path, const io::path& file )
return subB - subA; return subB - subA;
} }
// splits a path into components //! splits a path into components
static inline void splitFilename(const io::path &name, io::path* path=0, static inline void splitFilename(const io::path &name, io::path* path=0,
io::path* filename=0, io::path* extension=0, bool make_lower=false) io::path* filename=0, io::path* extension=0, bool make_lower=false)
{ {
...@@ -171,6 +171,29 @@ static inline void splitFilename(const io::path &name, io::path* path=0, ...@@ -171,6 +171,29 @@ static inline void splitFilename(const io::path &name, io::path* path=0,
*filename = name.subString ( 0, extpos, make_lower ); *filename = name.subString ( 0, extpos, make_lower );
} }
//! create a filename from components
static inline io::path mergeFilename(const io::path& path, const io::path& filename, const io::path& extension = "")
{
io::path result(path);
if ( !result.empty() )
{
fschar_t last = result.lastChar();
if ( last != _IRR_TEXT('/') && last != _IRR_TEXT('\\') )
result += _IRR_TEXT('/');
}
if ( !filename.empty() )
result += filename;
if ( !extension.empty() )
{
if ( !result.empty() && extension[0] != _IRR_TEXT('.') )
result += _IRR_TEXT('.');
result += extension;
}
return result;
}
//! some standard function ( to remove dependencies ) //! some standard function ( to remove dependencies )
#undef isdigit #undef isdigit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment