Generalize unlink to OS-dep code in Utils, just a little prep for Windows port.
This commit is contained in:
parent
8a46452a70
commit
86056fdbd9
3 changed files with 33 additions and 6 deletions
|
@ -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"
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue