Improvements to file uploads. UI improvements for future looper and audio capture plugins.

This commit is contained in:
Robin E. R. Davies
2025-02-15 12:29:53 -05:00
parent b07f590b49
commit 09f73e26d6
41 changed files with 1714 additions and 626 deletions
+57 -22
View File
@@ -20,67 +20,102 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#pragma once
#include <string>
#include <filesystem>
#include <vector>
#include <barrier>
#include <atomic>
#include <set>
namespace pipedal {
namespace pipedal
{
inline bool endsWith(const std::string& str, const std::string& suffix)
inline bool endsWith(const std::string &str, const std::string &suffix)
{
return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
return str.size() >= suffix.size() && 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix);
}
void SetThreadName(const std::string &name);
std::u32string ToUtf32(const std::string &s);
inline bool isPathSeperator(char c) { return c == '/' || c == std::filesystem::path::preferred_separator;}
inline bool isPathSeparator(char c) { return c == '/' || c == std::filesystem::path::preferred_separator; }
std::string GetHostName();
std::vector<std::string> split(const std::string &value, char delimiter);
inline void ReadBarrier() {
inline void ReadBarrier()
{
std::atomic_thread_fence(std::memory_order::acquire);
}
inline void WriteBarrier() {
inline void WriteBarrier()
{
std::atomic_thread_fence(std::memory_order::release);
}
template <typename T>
inline bool contains(const std::vector<T>&vector,const T&value)
inline bool contains(const std::vector<T> &vector, const T &value)
{
for (auto i = vector.begin(); i != vector.end(); ++i)
{
if ((*i) == value) {
if ((*i) == value)
{
return true;
}
}
return false;
}
inline bool contains(const std::vector<std::string>&vector,const char*value)
inline bool contains(const std::vector<std::string> &vector, const char *value)
{
return contains(vector,std::string(value));
return contains(vector, std::string(value));
}
class NoCopy {
class NoCopy
{
public:
NoCopy() { }
NoCopy(const NoCopy&) = delete;
NoCopy&operator=(const NoCopy&) = delete;
NoCopy() {}
NoCopy(const NoCopy &) = delete;
NoCopy &operator=(const NoCopy &) = delete;
~NoCopy() {}
};
class NoMove {
class NoMove
{
public:
NoMove() { }
NoMove(NoMove&&) = delete;
NoMove&operator=(NoMove&&) = delete;
~NoMove() { }
NoMove() {}
NoMove(NoMove &&) = delete;
NoMove &operator=(NoMove &&) = delete;
~NoMove() {}
};
bool IsChildDirectory(const std::filesystem::path &path, const std::filesystem::path&rootPath);
template <typename T>
std::set<T> Intersect(const std::set<T> &left, const std::set<T> &right)
{
std::set<T> result;
for (const T &v : left)
{
if (right.contains(v))
{
result.insert(v);
}
}
return result;
}
template <typename T>
bool IsSubset(const std::set<T> &subset, const std::set<T> &set)
{
std::set<T> result;
for (const T &v : subset)
{
if (!set.contains(v)) return false;
}
return true;
}
// C locale to lower. Only does 'A'-'Z'.
std::string ToLower(const std::string&value);
std::filesystem::path MakeRelativePath(const std::filesystem::path &path, const std::filesystem::path&parentPath);
}
+53
View File
@@ -21,6 +21,7 @@
* SOFTWARE.
*/
#include "util.hpp"
#include "ss.hpp"
#include <pthread.h>
#include <thread>
@@ -136,3 +137,55 @@ std::vector<std::string> pipedal::split(const std::string &value, char delimiter
}
return result;
}
bool pipedal::IsChildDirectory(const std::filesystem::path &path, const std::filesystem::path&rootPath)
{
auto iter = path.begin();
for (auto i = rootPath.begin(); i != rootPath.end(); ++i)
{
if (iter == path.end() || *iter != *i)
{
return false;
}
++iter;
}
return true;
}
std::string pipedal::ToLower(const std::string&value)
{
std::string result;
result.resize(value.length());
for (size_t i = 0; i < value.length(); ++i)
{
result[i] = (char)tolower(value[i]);
}
return result;
}
std::filesystem::path pipedal::MakeRelativePath(const std::filesystem::path &path, const std::filesystem::path&parentPath)
{
if (path.is_relative()) return path;
auto iter = path.begin();
for (auto i = parentPath.begin(); i != parentPath.end(); ++i)
{
if (iter == path.end() || *iter != *i) {
// not a child directory of parent directory.
throw std::runtime_error("Not a child directory.");
}
++iter;
}
std::filesystem::path remander;
while (iter != path.end())
{
remander /= *iter++;
}
return remander;
}