Skip to content
Snippets Groups Projects
Commit 2840d0f2 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

genFilename used string instead for char * .

[[Imported from SVN: r2014]]
parent d87a3cc8
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#define __MISC_HH__
#include <iostream>
#include <sstream>
//! Check condition at compilation time
template <bool flag> class CompileTimeChecker;
......@@ -39,31 +40,15 @@ namespace Dune {
//
//********************************************************************
template <typename T>
inline const char *genFilename(T *path, T *fn, int ntime, int precision = 6)
inline std::basic_string<char> genFilename(std::basic_string <char> path, std::basic_string <char> fn, int ntime, int precision = 6)
{
static char name[256];
char *cp;
std::ostringstream name;
if (path == 0 || path[0] == '\0')
{
sprintf(name, "%s", fn);
}
else
{
const char *cp = path;
while (*cp)
cp++;
cp--;
if (*cp == '/')
sprintf(name, "%s%s", path, fn);
else
sprintf(name, "%s/%s", path, fn);
}
cp = name;
while (*cp)
cp++;
name << path;
name << "/";
name << fn;
char cp[256];
switch(precision)
{
case 2 : { sprintf(cp, "%02d", ntime); break; }
......@@ -81,8 +66,10 @@ namespace Dune {
abort();
}
}
name << cp;
return( (T *) name);
// here implicitly a string is generated
return name.str().c_str();
}
/** @} */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment