From 86056fdbd923fbf55f85b3db704bba021ea90c4f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 8 Aug 2013 10:06:39 -0400 Subject: Generalize unlink to OS-dep code in Utils, just a little prep for Windows port. --- node/Utils.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'node/Utils.hpp') diff --git a/node/Utils.hpp b/node/Utils.hpp index a222ca4f..872201f8 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -43,6 +43,12 @@ #include "../ext/lz4/lz4.h" #include "../ext/lz4/lz4hc.h" +#ifdef __WINDOWS__ +#include +#else +#include +#endif + #include "Constants.hpp" /** @@ -58,6 +64,27 @@ namespace ZeroTier { class Utils { public: + /** + * Delete a file + * + * @param path Path to delete + * @return True if delete was successful + */ + static inline bool rm(const char *path) + throw() + { +#ifdef __WINDOWS__ + foo; +#else + return (unlink(path) == 0); +#endif + } + static inline bool rm(const std::string &path) + throw() + { + return rm(path.c_str()); + } + /** * List a directory's contents * -- cgit v1.2.3