Toob Player UI
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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 == '\\')
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user