Added osgDB::stringcopy and stringcopyfixedsize

This commit is contained in:
Robert Osfield 2016-06-25 16:08:15 +01:00
parent bc6a8948cc
commit 6d7d58fa12
2 changed files with 14 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include <string.h>
namespace osgDB {
@ -131,6 +132,11 @@ struct FileNameComparator
}
};
void stringcopy(char* dest, const char* src, size_t length);
#define stringcopyfixedsize(DEST, SRC) stringcopy(DEST, SRC, sizeof(DEST));
}
#endif

View File

@ -487,6 +487,14 @@ std::string osgDB::getPathRelative(const std::string& from, const std::string& t
return res;
}
void osgDB::stringcopy(char* dest, const char* src, size_t length)
{
strncpy(dest, src, length-1);
dest[length-1] = '\0';
OSG_NOTICE<<"osgDB::stringcopy(["<<dest<<"], src=["<<src<<"], "<<length<<")"<<std::endl;
}
//using namespace osgDB;
//std::string testA = getPathRelative("C:\\a\\b", "C:\\a/b/d/f"); // d/f
//std::string testB = getPathRelative("C:\\a\\d", "C:\\a/b/d/f"); // ../b/d/f