additional serial port data output, 3d model load failure caching, minor refactoring and bug fixes

This commit is contained in:
tmj-fstate
2018-03-11 15:48:30 +01:00
parent 0bf9d233aa
commit d96b259191
15 changed files with 58 additions and 62 deletions

View File

@@ -318,3 +318,19 @@ last_modified( std::string const &Filename ) {
if( ::stat( Filename.c_str(), &filestat ) == 0 ) { return filestat.st_mtime; }
else { return 0; }
}
// potentially erases file extension from provided file name. returns: true if extension was removed, false otherwise
bool
erase_extension( std::string &Filename ) {
auto const extensionpos { Filename.rfind( '.' ) };
if( extensionpos == std::string::npos ) { return false; }
if( extensionpos != Filename.rfind( ".." ) + 1 ) {
// we can get extension for .mat or, in legacy files, some image format. just trim it and set it to material file extension
Filename.erase( extensionpos );
return true;
}
return false;
}