nexuslua
Loading...
Searching...
No Matches
nexuslua::utility Namespace Reference

various helper functions More...

Functions

NEXUSLUA_EXPORT std::string ReadHttp (const std::string &URL, const std::string &outFile="", std::function< void(DownloadProgress, std::string)> progress=nullptr, std::function< bool()> abort=nullptr)
 reads a file from a the given URL (no https)
NEXUSLUA_EXPORT std::string ReadHttp (const std::string &host, const std::string &port, const std::string &path, const std::string &outFile="", std::function< void(DownloadProgress, std::string)> progress=nullptr, std::function< bool()> abort=nullptr)
 reads a file from a the given URL (no https)
NEXUSLUA_EXPORT std::string ReadHttps (const std::string &host, const std::string &port, const std::string &path, const std::string &outFile="", std::function< void(DownloadProgress, std::string)> progress=nullptr, std::function< bool()> abort=nullptr)
 reads a file from a the given URL
NEXUSLUA_EXPORT std::string RemoveWsFromParams (std::string signature)
 removes redundant white spaces from the given function signature
NEXUSLUA_EXPORT void ParseHostPortPath (std::string URL, std::string &host, std::string &port, std::string &path)
 splits up the given URL into the three components host, port and path and sets the reference parameters to these
NEXUSLUA_EXPORT bool Unzip (std::filesystem::path zip_file, std::filesystem::path target_dir)
 unzips the given zip file to the given target dir. Throws std::runtime_error in case of errors.
NEXUSLUA_EXPORT bool Zip (std::filesystem::path source_dir, std::filesystem::path zip_file)
 zips the given target directory to the given output zip file. Throws std::runtime_error in case of errors.

Detailed Description

various helper functions

Function Documentation

◆ ParseHostPortPath()

NEXUSLUA_EXPORT void nexuslua::utility::ParseHostPortPath ( std::string URL,
std::string & host,
std::string & port,
std::string & path )

splits up the given URL into the three components host, port and path and sets the reference parameters to these

◆ ReadHttp() [1/2]

NEXUSLUA_EXPORT std::string nexuslua::utility::ReadHttp ( const std::string & host,
const std::string & port,
const std::string & path,
const std::string & outFile = "",
std::function< void(DownloadProgress, std::string)> progress = nullptr,
std::function< bool()> abort = nullptr )

reads a file from a the given URL (no https)

Parameters
hostthe host to read from
portthe port to read from
paththe path on the host to read from
outFilean optional path to an output file
progressan optional callback function that will be called to set the progress during the download
abortan optional callback function that will be checked during download; if it returns true, the download will be canceled
Returns
the downloaded string, if outFile is empty; otherwise the empty string

◆ ReadHttp() [2/2]

NEXUSLUA_EXPORT std::string nexuslua::utility::ReadHttp ( const std::string & URL,
const std::string & outFile = "",
std::function< void(DownloadProgress, std::string)> progress = nullptr,
std::function< bool()> abort = nullptr )

reads a file from a the given URL (no https)

Parameters
URLthe URL to read from
outFilean optional path to an output file
progressan optional callback function that will be called to set the progress during the download
abortan optional callback function that will be checked during download; if it returns true, the download will be canceled
Returns
the downloaded string, if outFile is empty; otherwise the empty string

◆ ReadHttps()

NEXUSLUA_EXPORT std::string nexuslua::utility::ReadHttps ( const std::string & host,
const std::string & port,
const std::string & path,
const std::string & outFile = "",
std::function< void(DownloadProgress, std::string)> progress = nullptr,
std::function< bool()> abort = nullptr )

reads a file from a the given URL

Parameters
hostthe host to read from
portthe port to read from
paththe path on the host to read from
outFilean optional path to an output file
progressan optional callback function that will be called to set the progress during the download
abortan optional callback function that will be checked during download; if it returns true, the download will be canceled
Returns
the downloaded string, if outFile is empty; otherwise the empty string

◆ RemoveWsFromParams()

NEXUSLUA_EXPORT std::string nexuslua::utility::RemoveWsFromParams ( std::string signature)

removes redundant white spaces from the given function signature

◆ Unzip()

NEXUSLUA_EXPORT bool nexuslua::utility::Unzip ( std::filesystem::path zip_file,
std::filesystem::path target_dir )

unzips the given zip file to the given target dir. Throws std::runtime_error in case of errors.

◆ Zip()

NEXUSLUA_EXPORT bool nexuslua::utility::Zip ( std::filesystem::path source_dir,
std::filesystem::path zip_file )

zips the given target directory to the given output zip file. Throws std::runtime_error in case of errors.