diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-08 10:06:39 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-08 10:06:39 -0400 |
| commit | 86056fdbd923fbf55f85b3db704bba021ea90c4f (patch) | |
| tree | 1e8e46bf3fe85bf6ab9c91a98294479cf7e37626 /node/Utils.hpp | |
| parent | 8a46452a700fa5a8d6fc3bd9308bf483cd715de1 (diff) | |
| download | infinitytier-86056fdbd923fbf55f85b3db704bba021ea90c4f.tar.gz infinitytier-86056fdbd923fbf55f85b3db704bba021ea90c4f.zip | |
Generalize unlink to OS-dep code in Utils, just a little prep for Windows port.
Diffstat (limited to 'node/Utils.hpp')
| -rw-r--r-- | node/Utils.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
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 <windows.h> +#else +#include <unistd.h> +#endif + #include "Constants.hpp" /** @@ -59,6 +65,27 @@ 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 * * @param path Path to list |
