updated ZTO version

This commit is contained in:
Joseph Henry
2017-03-07 11:08:02 -08:00
parent ce42dd4815
commit 9016bc8385
132 changed files with 11902 additions and 10793 deletions

View File

@@ -45,6 +45,8 @@
#include <arpa/inet.h>
#endif
#include "../ext/json/json.hpp"
namespace ZeroTier {
/**
@@ -105,10 +107,26 @@ public:
* This returns only files, not sub-directories.
*
* @param path Path to list
* @return Names of files in directory
* @return Names of files in directory (without path prepended)
*/
static std::vector<std::string> listDirectory(const char *path);
/**
* List all contents in a directory
*
* @param path Path to list
* @return Names of things and types, currently just 'f' and 'd'
*/
static std::map<std::string,char> listDirectoryFull(const char *path);
/**
* Delete a directory and all its files and subdirectories recursively
*
* @param path Path to delete
* @return True on success
*/
static bool rmDashRf(const char *path);
/**
* Set modes on a file to something secure
*
@@ -220,6 +238,17 @@ public:
*/
static bool writeFile(const char *path,const void *buf,unsigned int len);
/**
* Split a string by delimiter, with optional escape and quote characters
*
* @param s String to split
* @param sep One or more separators
* @param esc Zero or more escape characters
* @param quot Zero or more quote characters
* @return Vector of tokens
*/
static std::vector<std::string> split(const char *s,const char *const sep,const char *esc,const char *quot);
/**
* Write a block of data to disk, replacing any current file contents
*
@@ -240,6 +269,13 @@ public:
*/
static std::string platformDefaultHomePath();
static nlohmann::json jsonParse(const std::string &buf);
static std::string jsonDump(const nlohmann::json &j);
static uint64_t jsonInt(const nlohmann::json &jv,const uint64_t dfl);
static bool jsonBool(const nlohmann::json &jv,const bool dfl);
static std::string jsonString(const nlohmann::json &jv,const char *dfl);
static std::string jsonBinFromHex(const nlohmann::json &jv);
private:
static const unsigned char TOLOWER_TABLE[256];
};