Added osgDB::stringcopy and stringcopyfixedsize
This commit is contained in:
parent
bc6a8948cc
commit
6d7d58fa12
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user