Toob Player UI

This commit is contained in:
Robin E. R. Davies
2025-06-07 21:52:23 -04:00
parent 82f94cb152
commit 6ea45f46df
29 changed files with 1860 additions and 319 deletions
+11
View File
@@ -39,6 +39,17 @@ std::string HtmlHelper::timeToHttpDate()
return timeToHttpDate(time(nullptr));
}
std::string HtmlHelper::timeToHttpDate(std::filesystem::file_time_type time)
{
// Convert to time_t.
std::chrono::system_clock::time_point system_time = std::chrono::clock_cast<std::chrono::system_clock>(time);
auto time_t_value = std::chrono::system_clock::to_time_t(system_time);
return timeToHttpDate(time_t_value);
}
std::string HtmlHelper::timeToHttpDate(time_t time)
{
// RFC 7231, IMF-fixdate.
+3
View File
@@ -21,6 +21,8 @@
#include <string>
#include <cstdint>
#include <chrono>
#include <filesystem>
namespace pipedal {
@@ -29,6 +31,7 @@ class HtmlHelper {
public:
static std::string timeToHttpDate();
static std::string timeToHttpDate(time_t time);
static std::string timeToHttpDate(std::filesystem::file_time_type time);
static std::string encode_url_segment(const char*pStart, const char*pEnd, bool isQuerySegment = false);
+4 -2
View File
@@ -71,6 +71,7 @@ namespace pipedal
return contains(vector, std::string(value));
}
bool HasWritePermissions(const std::filesystem::path &path);
class NoCopy
{
public:
@@ -114,11 +115,12 @@ namespace pipedal
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);
bool IsSubdirectory(const std::filesystem::path &path, const std::filesystem::path &basePath);
std::string ToLower(const std::string&value);
}
+1 -1
View File
@@ -123,7 +123,7 @@ void json_writer::write(string_view v,bool enforceValidUtf8Encoding)
if ((uc >= UTF16_SURROGATE_1_BASE && uc <= UTF16_SURROGATE_1_BASE + UTF16_SURROGATE_MASK) || (uc >= UTF16_SURROGATE_2_BASE && uc <= UTF16_SURROGATE_2_BASE + UTF16_SURROGATE_MASK))
{
// MUST not encode UTF16 surrogates in UTF8.
throw_encoding_error();
// throw_encoding_error();
}
if (uc == '"' || uc == '\\')
+10
View File
@@ -216,3 +216,13 @@ bool pipedal::IsSubdirectory(const std::filesystem::path &path, const std::files
}
return true;
}
bool pipedal::HasWritePermissions(const std::filesystem::path &path)
{
// posix, but may not work on windows.
// allegedly windows provies an _access function, which is probably a superset of
// access.
return access(path.c_str(), W_OK) == 0;
}