Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++ - Improved `Lockable` in several ways like adding `withLock()` (+ tests) - Improved `Semaphore` a bit for improved readability, and also added some tests - Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC - Simplification of WiFi connection - Updated funding options - (and more)
This commit is contained in:
committed by
GitHub
parent
1bb1260ea0
commit
6c67845645
@@ -1,21 +1,13 @@
|
||||
#include "StringUtils.h"
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace tt::string {
|
||||
|
||||
int findLastIndex(const char* text, size_t from_index, char find) {
|
||||
for (int i = (int)from_index; i >= 0; i--) {
|
||||
if (text[i] == find) {
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool getPathParent(const std::string& path, std::string& output) {
|
||||
int index = findLastIndex(path.c_str(), path.length() - 1, '/');
|
||||
if (index == -1) {
|
||||
auto index = path.find_last_of('/');
|
||||
if (index == std::string::npos) {
|
||||
return false;
|
||||
} else if (index == 0) {
|
||||
output = "/";
|
||||
|
||||
Reference in New Issue
Block a user