1
0
Fork 0

Add DEBUG messages for protected-file handling

This commit is contained in:
krcroft 2020-02-15 21:00:58 -08:00 committed by Patryk Obara
parent 9603c961c0
commit b302b535c3
3 changed files with 58 additions and 5 deletions

View file

@ -34,6 +34,24 @@
#include "support.h"
#include "video.h"
std::string get_basename(const std::string& filename) {
// Guard against corner cases: '', '/', '\', 'a'
if (filename.length() <= 1)
return filename;
// Find the last slash, but if not is set to zero
size_t slash_pos = filename.find_last_of("/\\");
// If the slash is the last character
if (slash_pos == filename.length() - 1)
slash_pos = 0;
// Otherwise if the slash is found mid-string
else if (slash_pos > 0)
slash_pos++;
return filename.substr(slash_pos);
}
void upcase(std::string &str) {
int (*tf)(int) = std::toupper;