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;
326 std::unique_ptr<char[]> formatted;
330 formatted.reset(
new char[n]);
331 strcpy(&formatted[0], fmt_str.c_str());
332 va_start(ap, fmt_str);
333 final_n = vsnprintf(&formatted[0], (
unsigned long)n, fmt_str.c_str(), ap);
335 if (final_n < 0 || final_n >= n)
336 n +=
abs(final_n - n + 1);
340 return string(formatted.get());
346 return (container.find(search) != string::npos);
352 return container.find(startStr) == 0;
358 if (container.length() >= endStr.length())
359 return (0 == container.compare(container.length() - endStr.length(),
369 string copy = inputDir;
371 string delimiter =
"\\";
374 while ((pos = copy.find(delimiter)) != string::npos)
376 token = copy.substr(0, pos);
377 copy.erase(0, pos + delimiter.length());
384 if (withTrailingSlash && !curr.empty() && curr.back() !=
'/')
393 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
394 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
395 if ((i1 != string::npos && i2 == string::npos) ||
396 (i1 != string::npos && i1 > i2))
398 return (pathFilename.substr(0, i1 + 1));
401 if ((i2 != string::npos && i1 == string::npos) ||
402 (i2 != string::npos && i2 > i1))
404 return (pathFilename.substr(0, i2 + 1));
411 vector<string>& vecOfStrings)
415 std::ifstream in(fileName.c_str());
420 std::cerr <<
"Cannot open the File : " << fileName << std::endl;
426 while (std::getline(in, str))
430 vecOfStrings.push_back(str);
465 const char* p1 = a.c_str();
466 const char* p2 = b.c_str();
467 const unsigned short st_scan = 0;
468 const unsigned short st_alpha = 1;
469 const unsigned short st_numeric = 2;
470 unsigned short state = st_scan;
471 const char* numstart1 =
nullptr;
472 const char* numstart2 =
nullptr;
473 const char* numend1 =
nullptr;
474 const char* numend2 =
nullptr;
475 unsigned long sz1 = 0;
476 unsigned long sz2 = 0;
483 if (!isdigit(*p1) && !isdigit(*p2))
494 else if (isdigit(*p1) && !isdigit(*p2))
496 else if (!isdigit(*p1) && isdigit(*p2))
508 while (*p1 ==
'0') p1++;
516 while (*p2 ==
'0') p2++;
522 if (!isdigit(*p1)) p1--;
523 if (!isdigit(*p2)) p2--;
531 if (!isdigit(*p1) && !isdigit(*p2))
545 while (isdigit(*p1)) numend1 = p1++;
546 while (isdigit(*p2)) numend2 = p2++;
547 if (numend1 - numstart1 == numend2 - numstart2 &&
548 !strncmp(numstart1, numstart2, numend2 - numstart2 + 1))
552 if (numend1 - numstart1 != numend2 - numstart2)
553 return numend1 - numstart1 < numend2 - numstart2;
554 while (*numstart1 && *numstart2)
556 if (*numstart1 != *numstart2)
return *numstart1 < *numstart2;
565 if (sz1 < sz2)
return true;
566 if (sz1 > sz2)
return false;
567 if (*p1 == 0 && *p2 != 0)
return true;
568 if (*p1 != 0 && *p2 == 0)
return false;
581 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
582 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
585 if (i1 != string::npos && i2 != string::npos)
586 i = (int)std::max(i1, i2);
587 else if (i1 != string::npos)
589 else if (i2 != string::npos)
592 return pathFilename.substr(i + 1, pathFilename.length() - i);
599 size_t i1 = pathFilename.rfind(
'\\', pathFilename.length());
600 size_t i2 = pathFilename.rfind(
'/', pathFilename.length());
603 if (i1 != string::npos && i2 != string::npos)
604 i = (int)std::max(i1, i2);
605 else if (i1 != string::npos)
607 else if (i2 != string::npos)
610 return pathFilename.substr(0, i + 1);
618 size_t i = filename.rfind(
'.', filename.length());
619 if (i != string::npos)
621 return (filename.substr(0, i));
630 size_t i = filename.rfind(
'.', filename.length());
631 if (i != string::npos)
632 return toLowerString(filename.substr(i + 1, filename.length() - i));
639 vector<string> filePathNames;
641 #if defined(USE_STD_FILESYSTEM)
642 if (
fs::exists(dirName) && fs::is_directory(dirName))
644 for (
const auto& entry : fs::directory_iterator(dirName))
646 auto filename = entry.path().filename();
647 if (fs::is_directory(entry.status()))
650 filePathNames.push_back(dirName +
"/" + filename.u8string());
652 filePathNames.push_back(filename.u8string());
657 DIR* dir = opendir(dirName.c_str());
661 struct dirent* dirContent =
nullptr;
663 while ((dirContent = readdir(dir)) !=
nullptr)
665 string name(dirContent->d_name);
667 if (name !=
"." && name !=
"..")
669 struct stat path_stat
672 stat((dirName + name).c_str(), &path_stat);
673 if (!S_ISREG(path_stat.st_mode))
676 filePathNames.push_back(dirName +
"/" + name);
678 filePathNames.push_back(name);
686 return filePathNames;
692 vector<string> filePathNames;
694 #if defined(USE_STD_FILESYSTEM)
695 if (
fs::exists(dirName) && fs::is_directory(dirName))
697 for (
const auto& entry : fs::directory_iterator(dirName))
699 auto filename = entry.path().filename();
701 filePathNames.push_back(dirName +
"/" + filename.u8string());
703 filePathNames.push_back(filename.u8string());
707 # if defined(TARGET_OS_IOS) && (TARGET_OS_IOS == 1)
710 DIR* dir = opendir(dirName.c_str());
714 struct dirent* dirContent =
nullptr;
716 while ((dirContent = readdir(dir)) !=
nullptr)
718 string name(dirContent->d_name);
719 if (name !=
"." && name !=
"..")
722 filePathNames.push_back(dirName +
"/" + name);
724 filePathNames.push_back(name);
732 return filePathNames;
738 vector<string> filePathNames;
740 #if defined(USE_STD_FILESYSTEM)
741 if (
fs::exists(dirName) && fs::is_directory(dirName))
743 for (
const auto& entry : fs::directory_iterator(dirName))
745 auto filename = entry.path().filename();
746 if (fs::is_regular_file(entry.status()))
749 filePathNames.push_back(dirName +
"/" + filename.u8string());
751 filePathNames.push_back(filename.u8string());
757 DIR* dir = opendir(dirName.c_str());
761 struct dirent* dirContent =
nullptr;
763 while ((dirContent = readdir(dir)) !=
nullptr)
765 string name(dirContent->d_name);
766 if (name !=
"." && name !=
"..")
768 struct stat path_stat
771 stat((dirName + name).c_str(), &path_stat);
772 if (S_ISREG(path_stat.st_mode))
775 filePathNames.push_back(dirName + name);
777 filePathNames.push_back(name);
785 return filePathNames;
791 #if defined(__EMSCRIPTEN__)
793 #elif defined(USE_STD_FILESYSTEM)
794 return fs::exists(path) && fs::is_directory(path);
799 if (stat(path.c_str(), &info) != 0)
801 else if (info.st_mode & S_IFDIR)
811 #if defined(USE_STD_FILESYSTEM)
812 return fs::create_directories(path);
815 return _mkdir(path.c_str());
817 int failed = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
818 bool result = !failed;
827 std::string delimiter =
"/";
830 std::string createdPath;
832 while ((pos = path.find(delimiter)) != std::string::npos)
834 createdPath += path.substr(0, pos) +
"/";
844 path.erase(0, pos + delimiter.length());
854 #if defined(USE_STD_FILESYSTEM)
855 fs::remove_all(path);
858 int ret = _rmdir(path.c_str());
863 log(
"Could not remove directory: %s\nErrno: %s\n", path.c_str(), strerror(errno));
876 #if defined(USE_STD_FILESYSTEM)
880 DeleteFileA(path.c_str());
882 unlink(path.c_str());
888 log(
"Could not remove file : %s\nErrno: %s\n",
890 "file does not exist");
896 #if defined(__EMSCRIPTEN__)
898 #elif defined(USE_STD_FILESYSTEM)
904 return (stat(pathfilename.c_str(), &info) == 0) && ((info.st_mode & S_IFDIR) == 0);
911 #if defined(USE_STD_FILESYSTEM)
913 return (
unsigned int)fs::file_size(pathfilename);
920 if (stat(pathfilename.c_str(), &st) != 0)
922 return (
unsigned int)st.st_size;
929 fs.seekg(0, std::ios::beg);
930 std::streampos begin = fs.tellg();
931 fs.seekg(0, std::ios::end);
932 std::streampos end = fs.tellg();
933 fs.seekg(0, std::ios::beg);
934 return (
unsigned int)(end - begin);
942 string appData = getenv(
"APPDATA");
943 string configDir = appData +
"/" + appName;
947 return configDir +
"/";
948 #elif defined(__APPLE__)
949 string home = getenv(
"HOME");
950 string appData = home +
"/Library/Application Support";
951 string configDir = appData +
"/" + appName;
953 mkdir(configDir.c_str(), S_IRWXU);
954 return configDir +
"/";
955 #elif defined(ANDROID) || defined(ANDROID_NDK)
957 #elif defined(linux) || defined(__linux) || defined(__linux__)
959 string home = getenv(
"HOME");
960 string configDir = home +
"/." + appName;
962 mkdir(configDir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
963 return configDir +
"/";
964 #elif defined(__EMSCRIPTEN__)
967 # error "No port to this OS"
976 # if defined(USE_STD_FILESYSTEM)
977 return fs::current_path().u8string();
980 char* buffer = (
char*)malloc(size);
981 if (_getcwd(buffer, size) == buffer)
991 #elif !defined(__EMSCRIPTEN__)
993 char* buffer = (
char*)malloc(size);
994 if (getcwd(buffer, size) == buffer)
995 return string(buffer) +
"/";
1008 return remove(pathfilename.c_str()) != 0;
1014 function<
void(
string path,
string baseName,
int depth)> processFile,
1015 function<
void(
string path,
string baseName,
int depth)> processDir,
1030 for (
const auto& fileOrFolder : unsortedNames)
1035 processFile(folder,
getFileName(fileOrFolder), depth);
1050 const char* tab =
" ";
1054 [logtag, tab](
string path,
string baseName,
int depth) ->
void {
1056 for (
int d = 0; d < depth; ++d)
1058 string indentFolderName = indent + baseName;
1059 Utils::log(logtag,
"%s", indentFolderName.c_str());
1061 [logtag, tab](
string path,
string baseName,
int depth) ->
void {
1063 for (
int d = 0; d < depth; ++d)
1065 string indentFolderName = indent +
"[" + baseName +
"]";
1066 Utils::log(logtag,
"%s", indentFolderName.c_str());
1074 string findFile(
const string& filename,
const vector<string>& pathsToCheck)
1080 for (
const auto& path : pathsToCheck)
1084 return pathPlusFilename;
1096 fileLog = std::make_unique<FileLog>(logDir, forceFlush);
1100 void log(
const char* tag,
const char* format, ...)
1105 va_start(argptr, format);
1106 vsnprintf(
log,
sizeof(
log), format, argptr);
1124 #if defined(ANDROID) || defined(ANDROID_NDK)
1125 __android_log_print(ANDROID_LOG_INFO, tag, msg);
1127 std::cout << msg << std::flush;
1147 #if defined(ANDROID) || defined(ANDROID_NDK)
1148 __android_log_print(ANDROID_LOG_WARN,
1150 "Warning: %s at line %d in %s\n",
1155 std::cout <<
"--------------------------------\n"
1157 <<
"Tag: " << tag <<
'\n'
1158 <<
"Location: " << file <<
":" << line <<
'\n'
1159 <<
"Message: " << msg <<
'\n'
1160 <<
"--------------------------------" << std::endl;
1170 #if defined(ANDROID) || defined(ANDROID_NDK)
1171 __android_log_print(ANDROID_LOG_ERROR,
1173 "Error: %s at line %d in %s\n",
1178 std::cout <<
"--------------------------------\n"
1180 <<
"Tag: " << tag <<
'\n'
1181 <<
"Location: " << file <<
":" << line <<
'\n'
1182 <<
"Message: " << msg <<
'\n'
1183 <<
"--------------------------------" << std::endl;
1190 #if defined(DEBUG) || defined(_DEBUG)
1193 return std::max(std::thread::hardware_concurrency(), 1U);
1208 return gcd(b, a % b);
1220 unsigned nextPow2 = 1;
1221 if (num <= 0)
return 1;
1223 while (nextPow2 <= num)
1225 unsigned prevPow2 = nextPow2 >> 1;
1227 if (num - prevPow2 < nextPow2 - num)
1236 unsigned nextPow2 = 1;
1237 if (num == 0)
return 1;
1239 while (nextPow2 <= num)
1263 const char* envvar = std::getenv(
"USER");
1264 user = envvar ? string(envvar) :
"USER?";
1265 if (
user ==
"USER?")
1267 const char* envvar = std::getenv(
"USERNAME");
1268 user = envvar ? string(envvar) :
"USER?";
1273 SYSTEM_INFO siSysInfo;
1274 GetSystemInfo(&siSysInfo);
1275 switch (siSysInfo.wProcessorArchitecture)
1277 case PROCESSOR_ARCHITECTURE_AMD64:
arch =
"x64";
break;
1278 case PROCESSOR_ARCHITECTURE_ARM:
arch =
"ARM";
break;
1279 case 12:
arch =
"ARM64";
break;
1280 case PROCESSOR_ARCHITECTURE_IA64:
arch =
"IA64";
break;
1281 case PROCESSOR_ARCHITECTURE_INTEL:
arch =
"x86";
break;
1282 default:
arch =
"???";
1289 RTL_OSVERSIONINFOW osInfo;
1290 ZeroMemory(&osInfo,
sizeof(osInfo));
1291 osInfo.dwOSVersionInfoSize =
sizeof(osInfo);
1293 typedef LONG(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
1294 if (HMODULE ntdll = GetModuleHandleW(L
"ntdll.dll"))
1296 auto rtlGetVersion =
reinterpret_cast<RtlGetVersionPtr
>(
1297 GetProcAddress(ntdll,
"RtlGetVersion"));
1299 rtlGetVersion(&osInfo);
1308 osInfo.dwMajorVersion,
1309 osInfo.dwMinorVersion,
1310 osInfo.dwBuildNumber);
1311 osVer = string(osVersion);
1317 #elif defined(__APPLE__)
1318 # if defined(TARGET_OS_IOS) && (TARGET_OS_IOS == 1)
1322 const char* envvar = std::getenv(
"USER");
1323 user = envvar ? string(envvar) :
"USER?";
1324 if (
user ==
"USER?")
1326 const char* envvar = std::getenv(
"USERNAME");
1327 user = envvar ? string(envvar) :
"USER?";
1332 const char* envvar = std::getenv(
"USER");
1333 user = envvar ? string(envvar) :
"USER?";
1335 if (
user ==
"USER?")
1337 const char* envvarUN = std::getenv(
"USERNAME");
1338 user = envvarUN ? string(envvarUN) :
"USER?";
1362 #elif defined(ANDROID)
1392 char hostC[PROP_VALUE_MAX];
1393 len = __system_property_get(
"ro.build.host", hostC);
1394 name = !string(hostC).empty() ? string(hostC) :
"NAME?";
1396 char userC[PROP_VALUE_MAX];
1397 len = __system_property_get(
"ro.build.user", userC);
1398 user = !string(userC).empty() ? string(userC) :
"USER?";
1400 char brandC[PROP_VALUE_MAX];
1401 len = __system_property_get(
"ro.product.brand", brandC);
1402 brand = string(brandC);
1404 char modelC[PROP_VALUE_MAX];
1405 len = __system_property_get(
"ro.product.model", modelC);
1406 model = string(modelC);
1408 char osVerC[PROP_VALUE_MAX];
1409 len = __system_property_get(
"ro.build.version.release", osVerC);
1410 osVer = string(osVerC);
1412 char archC[PROP_VALUE_MAX];
1413 len = __system_property_get(
"ro.product.cpu.abi", archC);
1414 arch = string(archC);
1416 #elif defined(linux) || defined(__linux) || defined(__linux__)
1429 if (
model.find(
"SM-") != string::npos)
1435 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.