25 #ifndef __EMSCRIPTEN__
27 # include <asio/ip/tcp.hpp>
32 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
33 # include <experimental/filesystem>
34 # define USE_STD_FILESYSTEM
35 namespace fs = std::experimental::filesystem;
39 #elif defined(__APPLE__)
40 # if defined(TARGET_OS_IOS) && (TARGET_OS_IOS == 1)
41 # include "Utils_iOS.h"
43 # include <sys/stat.h>
46 # include <filesystem>
47 # define USE_STD_FILESYSTEM
48 namespace fs = std::filesystem;
50 #elif defined(ANDROID) || defined(ANDROID_NDK)
51 # include <android/log.h>
54 # include <sys/stat.h>
55 # include <sys/time.h>
56 # include <sys/system_properties.h>
57 #elif defined(linux) || defined(__linux) || defined(__linux__)
60 # include <sys/types.h>
61 # include <sys/stat.h>
62 #elif defined(__EMSCRIPTEN__)
63 # include <emscripten.h>
66 # include <sys/types.h>
67 # include <sys/stat.h>
70 #ifndef __EMSCRIPTEN__
95 ss << std::fixed << std::setprecision(roundedDecimals) << f;
96 string num = ss.str();
97 if (num ==
"-0.0") num =
"0.0";
105 ss << std::fixed << std::setprecision(roundedDecimals) << d;
106 string num = ss.str();
107 if (num ==
"-0.0") num =
"0.0";
114 string cpy(std::move(
s));
115 transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower);
122 string cpy(std::move(
s));
123 transform(cpy.begin(), cpy.end(), cpy.begin(), ::toupper);
131 r = r.erase(r.find_last_not_of(drop) + 1);
132 return r.erase(0, r.find_first_not_of(drop));
139 r = r.erase(r.find_last_not_of(drop) + 1);
147 r = r.erase(r.find_first_not_of(drop) + 1);
154 vector<string>& splits)
156 string::size_type i = 0;
157 string::size_type j =
s.find(delimiter);
159 while (j != string::npos)
161 splits.push_back(
s.substr(i, j - i));
163 j =
s.find(delimiter, j);
164 if (j == string::npos)
165 splits.push_back(
s.substr(i,
s.length()));
177 newString.reserve(source.length());
179 string::size_type lastPos = 0;
180 string::size_type findPos = 0;
182 while (string::npos != (findPos = source.find(from, lastPos)))
184 newString.append(source, lastPos, findPos - lastPos);
186 lastPos = findPos + from.length();
190 newString += source.substr(lastPos);
191 source.swap(newString);
197 std::stringstream stream(multiLineString);
198 std::vector<std::string> res;
202 std::getline(stream, line);
214 fstream shaderFile(pathAndFilename.c_str(), std::ios::in);
216 if (!shaderFile.is_open())
219 "File open failed in readTextFileIntoString: %s",
220 pathAndFilename.c_str());
224 std::stringstream buffer;
225 buffer << shaderFile.rdbuf();
231 const string& stringToWrite,
232 const string& pathAndFilename)
234 std::ofstream file(pathAndFilename);
235 file << stringToWrite;
238 "Writing file failed in writeStringIntoTextFile: %s",
239 pathAndFilename.c_str());
246 std::replace(src.begin(), src.end(),
'/', replaceChar);
247 std::replace(src.begin(), src.end(),
'\\', replaceChar);
248 std::replace(src.begin(), src.end(),
'|', replaceChar);
249 std::replace(src.begin(), src.end(),
'?', replaceChar);
250 std::replace(src.begin(), src.end(),
'%', replaceChar);
251 std::replace(src.begin(), src.end(),
'*', replaceChar);
252 std::replace(src.begin(), src.end(),
':', replaceChar);
253 std::replace(src.begin(), src.end(),
'"', replaceChar);
262 struct tm* t2 = localtime(&tm);
264 strftime(buf,
sizeof(buf),
"%c", t2);
273 struct tm* t = localtime(&tm);
275 static char shortTime[50];
278 "%.2d.%.2d.%.2d-%.2d:%.2d",
285 return string(shortTime);
293 struct tm* t = localtime(&tm);
295 static char shortTime[50];
298 "%.4d%.2d%.2d-%.2d%.2d%.2d",
306 return string(shortTime);
312 #ifndef __EMSCRIPTEN__
313 return asio::ip::host_name();
324 int n = ((int)fmt_str.size()) * 2;
327 std::unique_ptr<char[]> formatted;
331 formatted.reset(
new char[n]);
332 strcpy(&formatted[0], fmt_str.c_str());
333 va_start(ap, fmt_str);
334 final_n = vsnprintf(&formatted[0], (
unsigned long)n, fmt_str.c_str(), ap);
336 if (final_n < 0 || final_n >= n)
337 n +=
abs(final_n - n + 1);
341 return string(formatted.get());
347 return (container.find(search) != string::npos);
353 return container.find(startStr) == 0;
359 if (container.length() >= endStr.length())
360 return (0 == container.compare(container.length() - endStr.length(),
370 string copy = inputDir;
372 string delimiter =
"\\";
375 while ((pos = copy.find(delimiter)) != string::npos)
377 token = copy.substr(0, pos);
378 copy.erase(0, pos + delimiter.length());
385 if (withTrailingSlash && !curr.empty() && curr.back() !=
'/')
394 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
395 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
396 if ((i1 != string::npos && i2 == string::npos) ||
397 (i1 != string::npos && i1 > i2))
399 return (pathFilename.substr(0, i1 + 1));
402 if ((i2 != string::npos && i1 == string::npos) ||
403 (i2 != string::npos && i2 > i1))
405 return (pathFilename.substr(0, i2 + 1));
412 vector<string>& vecOfStrings)
416 std::ifstream in(fileName.c_str());
421 std::cerr <<
"Cannot open the File : " << fileName << std::endl;
427 while (std::getline(in, str))
431 vecOfStrings.push_back(str);
466 const char* p1 = a.c_str();
467 const char* p2 = b.c_str();
468 const unsigned short st_scan = 0;
469 const unsigned short st_alpha = 1;
470 const unsigned short st_numeric = 2;
471 unsigned short state = st_scan;
472 const char* numstart1 =
nullptr;
473 const char* numstart2 =
nullptr;
474 const char* numend1 =
nullptr;
475 const char* numend2 =
nullptr;
476 unsigned long sz1 = 0;
477 unsigned long sz2 = 0;
484 if (!isdigit(*p1) && !isdigit(*p2))
495 else if (isdigit(*p1) && !isdigit(*p2))
497 else if (!isdigit(*p1) && isdigit(*p2))
509 while (*p1 ==
'0') p1++;
517 while (*p2 ==
'0') p2++;
523 if (!isdigit(*p1)) p1--;
524 if (!isdigit(*p2)) p2--;
532 if (!isdigit(*p1) && !isdigit(*p2))
546 while (isdigit(*p1)) numend1 = p1++;
547 while (isdigit(*p2)) numend2 = p2++;
548 if (numend1 - numstart1 == numend2 - numstart2 &&
549 !strncmp(numstart1, numstart2, numend2 - numstart2 + 1))
553 if (numend1 - numstart1 != numend2 - numstart2)
554 return numend1 - numstart1 < numend2 - numstart2;
555 while (*numstart1 && *numstart2)
557 if (*numstart1 != *numstart2)
return *numstart1 < *numstart2;
566 if (sz1 < sz2)
return true;
567 if (sz1 > sz2)
return false;
568 if (*p1 == 0 && *p2 != 0)
return true;
569 if (*p1 != 0 && *p2 == 0)
return false;
582 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
583 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
586 if (i1 != string::npos && i2 != string::npos)
587 i = (int)std::max(i1, i2);
588 else if (i1 != string::npos)
590 else if (i2 != string::npos)
593 return pathFilename.substr(i + 1, pathFilename.length() - i);
600 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
601 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
604 if (i1 != string::npos && i2 != string::npos)
605 i = (int)std::max(i1, i2);
606 else if (i1 != string::npos)
608 else if (i2 != string::npos)
611 return pathFilename.substr(0, i + 1);
619 size_t i = filename.rfind(
'.', filename.length());
620 if (i != string::npos)
622 return (filename.substr(0, i));
631 size_t i = filename.rfind(
'.', filename.length());
632 if (i != string::npos)
633 return toLowerString(filename.substr(i + 1, filename.length() - i));
640 vector<string> filePathNames;
642 #if defined(USE_STD_FILESYSTEM)
643 if (
fs::exists(dirName) && fs::is_directory(dirName))
645 for (
const auto& entry : fs::directory_iterator(dirName))
647 auto filename = entry.path().filename();
648 if (fs::is_directory(entry.status()))
651 filePathNames.push_back(dirName +
"/" + filename.u8string());
653 filePathNames.push_back(filename.u8string());
658 DIR* dir = opendir(dirName.c_str());
662 struct dirent* dirContent =
nullptr;
664 while ((dirContent = readdir(dir)) !=
nullptr)
666 string name(dirContent->d_name);
668 if (name !=
"." && name !=
"..")
670 struct stat path_stat
673 stat((dirName + name).c_str(), &path_stat);
674 if (!S_ISREG(path_stat.st_mode))
677 filePathNames.push_back(dirName +
"/" + name);
679 filePathNames.push_back(name);
687 return filePathNames;
693 vector<string> filePathNames;
695 #if defined(USE_STD_FILESYSTEM)
696 if (
fs::exists(dirName) && fs::is_directory(dirName))
698 for (
const auto& entry : fs::directory_iterator(dirName))
700 auto filename = entry.path().filename();
702 filePathNames.push_back(dirName +
"/" + filename.u8string());
704 filePathNames.push_back(filename.u8string());
708 # if defined(TARGET_OS_IOS) && (TARGET_OS_IOS == 1)
711 DIR* dir = opendir(dirName.c_str());
715 struct dirent* dirContent =
nullptr;
717 while ((dirContent = readdir(dir)) !=
nullptr)
719 string name(dirContent->d_name);
720 if (name !=
"." && name !=
"..")
723 filePathNames.push_back(dirName +
"/" + name);
725 filePathNames.push_back(name);
733 return filePathNames;
739 vector<string> filePathNames;
741 #if defined(USE_STD_FILESYSTEM)
742 if (
fs::exists(dirName) && fs::is_directory(dirName))
744 for (
const auto& entry : fs::directory_iterator(dirName))
746 auto filename = entry.path().filename();
747 if (fs::is_regular_file(entry.status()))
750 filePathNames.push_back(dirName +
"/" + filename.u8string());
752 filePathNames.push_back(filename.u8string());
758 DIR* dir = opendir(dirName.c_str());
762 struct dirent* dirContent =
nullptr;
764 while ((dirContent = readdir(dir)) !=
nullptr)
766 string name(dirContent->d_name);
767 if (name !=
"." && name !=
"..")
769 struct stat path_stat
772 stat((dirName + name).c_str(), &path_stat);
773 if (S_ISREG(path_stat.st_mode))
776 filePathNames.push_back(dirName + name);
778 filePathNames.push_back(name);
786 return filePathNames;
792 #if defined(__EMSCRIPTEN__)
794 #elif defined(USE_STD_FILESYSTEM)
795 return fs::exists(path) && fs::is_directory(path);
800 if (stat(path.c_str(), &info) != 0)
802 else if (info.st_mode & S_IFDIR)
812 #if defined(USE_STD_FILESYSTEM)
813 return fs::create_directories(path);
816 return _mkdir(path.c_str());
818 int failed = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
819 bool result = !failed;
828 std::string delimiter =
"/";
833 std::string createdPath;
835 while ((pos = path.find(delimiter)) != std::string::npos)
837 createdPath += path.substr(0, pos) +
"/";
847 path.erase(0, pos + delimiter.length());
857 #if defined(USE_STD_FILESYSTEM)
858 fs::remove_all(path);
861 int ret = _rmdir(path.c_str());
866 log(
"Could not remove directory: %s\nErrno: %s\n", path.c_str(), strerror(errno));
879 #if defined(USE_STD_FILESYSTEM)
883 DeleteFileA(path.c_str());
885 unlink(path.c_str());
891 log(
"Could not remove file : %s\nErrno: %s\n",
893 "file does not exist");
899 #if defined(__EMSCRIPTEN__)
901 #elif defined(USE_STD_FILESYSTEM)
907 return (stat(pathfilename.c_str(), &info) == 0) && ((info.st_mode & S_IFDIR) == 0);
914 #if defined(USE_STD_FILESYSTEM)
916 return (
unsigned int)fs::file_size(pathfilename);
923 if (stat(pathfilename.c_str(), &st) != 0)
925 return (
unsigned int)st.st_size;
932 fs.seekg(0, std::ios::beg);
933 std::streampos begin = fs.tellg();
934 fs.seekg(0, std::ios::end);
935 std::streampos end = fs.tellg();
936 fs.seekg(0, std::ios::beg);
937 return (
unsigned int)(end - begin);
945 string appData = getenv(
"APPDATA");
946 string configDir = appData +
"/" + appName;
950 return configDir +
"/";
951 #elif defined(__APPLE__)
952 string home = getenv(
"HOME");
953 string appData = home +
"/Library/Application Support";
954 string configDir = appData +
"/" + appName;
956 mkdir(configDir.c_str(), S_IRWXU);
957 return configDir +
"/";
958 #elif defined(ANDROID) || defined(ANDROID_NDK)
960 #elif defined(linux) || defined(__linux) || defined(__linux__)
962 string home = getenv(
"HOME");
963 string configDir = home +
"/." + appName;
965 mkdir(configDir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
966 return configDir +
"/";
967 #elif defined(__EMSCRIPTEN__)
970 # error "No port to this OS"
979 # if defined(USE_STD_FILESYSTEM)
980 return fs::current_path().u8string();
983 char* buffer = (
char*)malloc(size);
984 if (_getcwd(buffer, size) == buffer)
994 #elif !defined(__EMSCRIPTEN__)
996 char* buffer = (
char*)malloc(size);
997 if (getcwd(buffer, size) == buffer)
998 return string(buffer) +
"/";
1011 return remove(pathfilename.c_str()) != 0;
1017 function<
void(
string path,
string baseName,
int depth)> processFile,
1018 function<
void(
string path,
string baseName,
int depth)> processDir,
1033 for (
const auto& fileOrFolder : unsortedNames)
1038 processFile(folder,
getFileName(fileOrFolder), depth);
1053 const char* tab =
" ";
1057 [logtag, tab](
string path,
string baseName,
int depth) ->
void {
1059 for (
int d = 0; d < depth; ++d)
1061 string indentFolderName = indent + baseName;
1062 Utils::log(logtag,
"%s", indentFolderName.c_str());
1064 [logtag, tab](
string path,
string baseName,
int depth) ->
void {
1066 for (
int d = 0; d < depth; ++d)
1068 string indentFolderName = indent +
"[" + baseName +
"]";
1069 Utils::log(logtag,
"%s", indentFolderName.c_str());
1077 string findFile(
const string& filename,
const vector<string>& pathsToCheck)
1083 for (
const auto& path : pathsToCheck)
1087 return pathPlusFilename;
1099 fileLog = std::make_unique<FileLog>(logDir, forceFlush);
1103 void log(
const char* tag,
const char* format, ...)
1108 va_start(argptr, format);
1109 vsnprintf(
log,
sizeof(
log), format, argptr);
1127 #if defined(ANDROID) || defined(ANDROID_NDK)
1128 __android_log_print(ANDROID_LOG_INFO, tag, msg);
1130 std::cout << msg << std::flush;
1150 #if defined(ANDROID) || defined(ANDROID_NDK)
1151 __android_log_print(ANDROID_LOG_WARN,
1153 "Warning: %s at line %d in %s\n",
1158 std::cout <<
"--------------------------------\n"
1160 <<
"Tag: " << tag <<
'\n'
1161 <<
"Location: " << file <<
":" << line <<
'\n'
1162 <<
"Message: " << msg <<
'\n'
1163 <<
"--------------------------------" << std::endl;
1173 #if defined(ANDROID) || defined(ANDROID_NDK)
1174 __android_log_print(ANDROID_LOG_ERROR,
1176 "Error: %s at line %d in %s\n",
1181 std::cout <<
"--------------------------------\n"
1183 <<
"Tag: " << tag <<
'\n'
1184 <<
"Location: " << file <<
":" << line <<
'\n'
1185 <<
"Message: " << msg <<
'\n'
1186 <<
"--------------------------------" << std::endl;
1193 #if defined(DEBUG) || defined(_DEBUG)
1196 return std::max(std::thread::hardware_concurrency(), 1U);
1211 return gcd(b, a % b);
1223 unsigned nextPow2 = 1;
1224 if (num <= 0)
return 1;
1226 while (nextPow2 <= num)
1228 unsigned prevPow2 = nextPow2 >> 1;
1230 if (num - prevPow2 < nextPow2 - num)
1239 unsigned nextPow2 = 1;
1240 if (num == 0)
return 1;
1242 while (nextPow2 <= num)
1266 const char* envvar = std::getenv(
"USER");
1267 user = envvar ? string(envvar) :
"USER?";
1268 if (
user ==
"USER?")
1270 const char* envvar = std::getenv(
"USERNAME");
1271 user = envvar ? string(envvar) :
"USER?";
1276 SYSTEM_INFO siSysInfo;
1277 GetSystemInfo(&siSysInfo);
1278 switch (siSysInfo.wProcessorArchitecture)
1280 case PROCESSOR_ARCHITECTURE_AMD64:
arch =
"x64";
break;
1281 case PROCESSOR_ARCHITECTURE_ARM:
arch =
"ARM";
break;
1282 case 12:
arch =
"ARM64";
break;
1283 case PROCESSOR_ARCHITECTURE_IA64:
arch =
"IA64";
break;
1284 case PROCESSOR_ARCHITECTURE_INTEL:
arch =
"x86";
break;
1285 default:
arch =
"???";
1289 OSVERSIONINFO osInfo;
1290 ZeroMemory(&osInfo,
sizeof(OSVERSIONINFO));
1291 osInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
1292 GetVersionEx(&osInfo);
1294 sprintf(osVersion,
"%lu.%lu", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
1295 osVer = string(osVersion);
1301 #elif defined(__APPLE__)
1302 # if defined(TARGET_OS_IOS) && (TARGET_OS_IOS == 1)
1306 const char* envvar = std::getenv(
"USER");
1307 user = envvar ? string(envvar) :
"USER?";
1308 if (
user ==
"USER?")
1310 const char* envvar = std::getenv(
"USERNAME");
1311 user = envvar ? string(envvar) :
"USER?";
1316 const char* envvar = std::getenv(
"USER");
1317 user = envvar ? string(envvar) :
"USER?";
1319 if (
user ==
"USER?")
1321 const char* envvarUN = std::getenv(
"USERNAME");
1322 user = envvarUN ? string(envvarUN) :
"USER?";
1346 #elif defined(ANDROID)
1376 char hostC[PROP_VALUE_MAX];
1377 len = __system_property_get(
"ro.build.host", hostC);
1378 name = !string(hostC).empty() ? string(hostC) :
"NAME?";
1380 char userC[PROP_VALUE_MAX];
1381 len = __system_property_get(
"ro.build.user", userC);
1382 user = !string(userC).empty() ? string(userC) :
"USER?";
1384 char brandC[PROP_VALUE_MAX];
1385 len = __system_property_get(
"ro.product.brand", brandC);
1386 brand = string(brandC);
1388 char modelC[PROP_VALUE_MAX];
1389 len = __system_property_get(
"ro.product.model", modelC);
1390 model = string(modelC);
1392 char osVerC[PROP_VALUE_MAX];
1393 len = __system_property_get(
"ro.build.version.release", osVerC);
1394 osVer = string(osVerC);
1396 char archC[PROP_VALUE_MAX];
1397 len = __system_property_get(
"ro.product.cpu.abi", archC);
1398 arch = string(archC);
1400 #elif defined(linux) || defined(__linux) || defined(__linux__)
1413 if (
model.find(
"SM-") != string::npos)
1419 std::replace(
id.begin(),
id.end(),
'_',
'-');
The SLScene class represents the top level instance holding the scene structure.
static std::vector< std::string > getAllNamesInDir(const std::string &dirName, bool fullPath=true)
Returns all files and folders in a directory as a vector.
bool exists(std::string path, SLIOStreamKind kind)
Checks whether a given file exists.
Utils provides utilities for string & file handling, logging and math functions.
string findFile(const string &filename, const vector< string > &pathsToCheck)
Tries to find a filename on various paths to check.
vector< string > getDirNamesInDir(const string &dirName, bool fullPath)
Returns a vector directory names with path in dir.
string getDateTime2String()
Returns local time as string like "20190213-154611".
string unifySlashes(const string &inputDir, bool withTrailingSlash)
Returns the inputDir string with unified forward slashes, e.g.: "dirA/dirB/".
bool fileExists(const string &pathfilename)
Returns true if a file exists.
bool dirExists(const string &path)
Returns true if a directory exists.
bool makeDir(const string &path)
Creates a directory with given path.
bool getFileContent(const string &fileName, vector< string > &vecOfStrings)
Returns true if content of file could be put in a vector of strings.
unsigned nextPowerOf2(unsigned num)
Returns the next power of 2 to a passed number.
void removeDir(const string &path)
RemoveDir deletes a directory with given path.
string getHostName()
Returns the computer name.
bool containsString(const string &container, const string &search)
Returns true if container contains the search string.
void dumpFileSystemRec(const char *logtag, const string &folderPath)
Dumps all folders and files recursovely.
vector< string > getStringLines(const string &multiLineString)
Returns a vector of string one per line of a multiline string.
void errorMsg(const char *tag, const char *msg, const int line, const char *file)
Platform independent error message output.
string getFileNameWOExt(const string &pathFilename)
Returns the filename without extension.
bool compareNatural(const string &a, const string &b)
Naturally compares two strings (used for filename sorting)
string trimLeftString(const string &s, const string &drop)
trims a string at the left end
std::unique_ptr< CustomLog > customLog
custom log instance, e.g. log to a ui log window
unsigned int getFileSize(const string &pathfilename)
Returns the file size in bytes.
string formatString(string fmt_str,...)
Returns a formatted string as sprintf.
string getFileName(const string &pathFilename)
Returns the filename of path-filename string.
string replaceNonFilenameChars(string src, const char replaceChar)
replaces non-filename characters: /|?%*:"<>'
void splitString(const string &s, char delimiter, vector< string > &splits)
Splits an input string at a delimiter character into a string vector.
string getPath(const string &pathFilename)
Returns the path w. '\' of path-filename string.
void warnMsg(const char *tag, const char *msg, const int line, const char *file)
Platform independent warn message output.
void exitMsg(const char *tag, const char *msg, const int line, const char *file)
Terminates the application with a message. No leak checking.
string toUpperString(string s)
Returns a string in upper case.
static std::unique_ptr< FileLog > fileLog
unsigned int maxThreads()
Returns in release config the max. NO. of threads otherwise 1.
vector< string > getFileNamesInDir(const string &dirName, bool fullPath)
Returns a vector of sorted filesnames in dirName.
string getDirName(const string &pathFilename)
Strip last component from file name.
void removeFile(const string &path)
RemoveFile deletes a file with given path.
vector< string > getAllNamesInDir(const string &dirName, bool fullPath)
Returns a vector of sorted names (files and directories) with path in dir.
string getCurrentWorkingDir()
Returns the working directory.
unsigned closestPowerOf2(unsigned num)
Returns the closest power of 2 to a passed number.
string getLocalTimeString()
Returns local time as string like "Wed Feb 13 15:46:11 2019".
string trimString(const string &s, const string &drop)
Trims a string at both end.
string getAppsWritableDir(string appName)
Returns the writable configuration directory.
int gcd(int a, int b)
Greatest common divisor of two integer numbers (ggT = grösster gemeinsame Teiler)
string trimRightString(const string &s, const string &drop)
trims a string at the right end
bool makeDirRecurse(std::string path)
bool startsWithString(const string &container, const string &startStr)
Return true if the container string starts with the startStr.
void loopFileSystemRec(const string &path, function< void(string path, string baseName, int depth)> processFile, function< void(string path, string baseName, int depth)> processDir, const int depth)
process all files and folders recursively naturally sorted
string toString(float f, int roundedDecimals)
Returns a string from a float with max. one trailing zero.
bool endsWithString(const string &container, const string &endStr)
Return true if the container string ends with the endStr.
void replaceString(string &source, const string &from, const string &to)
Replaces in the source string the from string by the to string.
bool deleteFile(string &pathfilename)
Deletes a file on the filesystem.
string readTextFileIntoString(const char *logTag, const string &pathAndFilename)
Reads a text file into a string and returns it.
string getDateTime1String()
Returns local time as string like "13.02.19-15:46".
bool onlyErrorLogs
if this flag is set to true all calls to log get ignored
string toLowerString(string s)
Returns a string in lower case.
void log(const char *tag, const char *format,...)
logs a formatted string platform independently
void writeStringIntoTextFile(const char *logTag, const string &stringToWrite, const string &pathAndFilename)
Writes a string into a text file.
void initFileLog(const string &logDir, bool forceFlush)
string getFileExt(const string &filename)
Returns the file extension without dot in lower case.