#ifndef SYS_UTIL_H
#define SYS_UTIL_H
#include <filesystem>
#include <memory>
#include <string>


namespace zsy
{
    class SysUtil
    {
    public:
        static std::string WORK_DIR;
        static std::string HOME_DIR;

        static std::wstring str_a_w(const std::string &astr, const char *encode = "UTF-8");

        static std::string str_w_a(const std::wstring &wstr, const char *encode = "UTF-8");

        static std::shared_ptr<wchar_t[]> ch_a_w(const char *ach);

        static std::shared_ptr<char[]> ch_w_a(const wchar_t *wch);

        static std::shared_ptr<wchar_t[]> ch_vlt(const wchar_t *wch);

        static std::shared_ptr<char[]> ch_vlt(const char *ach);

        static std::tuple<bool, uint64_t, std::string> getError();

        static std::string toHex(uint64_t value, int width = 2, bool uppercase = true);

        static std::string sha1(const std::string &data);

        static std::string hmac_sha1(const std::string &key, const std::string &data);

        static std::string base64_encode(const unsigned char *data, size_t length);

        static std::string base64_encode(const std::string &data)
        {
            return base64_encode(
                reinterpret_cast<const unsigned char *>(data.data()),
                data.length()
            );
        }

        static std::string base64_decode(const unsigned char *data, size_t length);

        static std::string base64_decode(const std::string &data)
        {
            return base64_decode(
                reinterpret_cast<const unsigned char *>(data.data()),
                data.length()
            );
        }

        static void createDirs(const std::filesystem::path &path);
    };
}


#endif //SYS_UTIL_H
