1
0
This repository has been archived on 2025-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
siadrive/SiaDrive.Api/SiaApi.cpp
2017-02-16 22:30:49 -06:00

51 lines
806 B
C++

#include "stdafx.h"
#include "SiaApi.h"
#include <regex>
using namespace Sia::Api;
CSiaApi::CSiaApi(const SiaHostConfig& hostConfig) :
_siaCurl(hostConfig),
_wallet(new CSiaWallet(_siaCurl)),
_renter(new CSiaRenter(_siaCurl))
{
}
CSiaApi::~CSiaApi()
{
//TODO Make this an option to lock on exit
//_wallet->Lock();
}
String CSiaApi::FormatToSiaPath(String path)
{
if (path.length())
{
std::replace(path.begin(), path.end(), '\\', '/');
std::wregex r(L"/+");
path = std::regex_replace(path, r, L"/");
while (path[0] == '/')
{
path = path.substr(1);
}
}
return path;
}
String CSiaApi::GetServerVersion() const
{
return _siaCurl.GetServerVersion();
}
CSiaWalletPtr CSiaApi::GetWallet() const
{
return _wallet;
}
CSiaRenterPtr CSiaApi::GetRenter() const
{
return _renter;
}