Imported Upstream version 1.2.4

This commit is contained in:
didyouexpectthat 2018-01-12 18:20:00 -08:00
commit 4722a0b75a
398 changed files with 38633 additions and 24919 deletions

View file

@ -45,6 +45,8 @@
#include <arpa/inet.h>
#endif
#include "../ext/json/json.hpp"
namespace ZeroTier {
/**
@ -102,12 +104,29 @@ public:
/**
* List a directory's contents
*
* This returns only files, not sub-directories.
*
* @param path Path to list
* @return Names of files in directory
* @param includeDirectories If true, include directories as well as files
* @return Names of files in directory (without path prepended)
*/
static std::vector<std::string> listDirectory(const char *path);
static std::vector<std::string> listDirectory(const char *path,bool includeDirectories = false);
/**
* Clean a directory of files whose last modified time is older than this
*
* This ignores directories, symbolic links, and other special files.
*
* @param olderThan Last modified older than timestamp (ms since epoch)
* @return Number of cleaned files or negative on fatal error
*/
static long cleanDirectory(const char *path,const uint64_t olderThan);
/**
* 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 +239,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 +270,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];
};