Fixed building on posix

This commit is contained in:
Adrian Ebeling 2019-01-20 14:24:45 +01:00
parent a57957702e
commit 69d891ab3b

View File

@ -35,6 +35,7 @@ limitations under the License.
#include <sys/types.h> // required for stat.h #include <sys/types.h> // required for stat.h
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <ftw.h>
#ifdef __GLIBC__ #ifdef __GLIBC__
#include <malloc.h> #include <malloc.h>
#endif #endif
@ -138,15 +139,15 @@ static int nftwCallback(const char *name, const struct stat * /*unused*/,
return 0; return 0;
} }
void RemoveDirectoryRecursive(const AbsolutePath &path) { void RemoveDirectoryRecursive(const std::string &path) {
// https://stackoverflow.com/a/5467788/2192139 // https://stackoverflow.com/a/5467788/2192139
nftw(path.path.c_str(), nftwCallback, 64, FTW_DEPTH | FTW_PHYS); nftw(path.c_str(), nftwCallback, 64, FTW_DEPTH | FTW_PHYS);
} }
optional<std::string> TryMakeTempDirectory() { std::optional<std::string> TryMakeTempDirectory() {
char tmpl[] = "/tmp/ccls-XXXXXX"; char tmpl[] = "/tmp/ccls-XXXXXX";
if(!mkdtemp(tmpl)) { if(!mkdtemp(tmpl)) {
return nullopt; return std::nullopt;
} }
return tmpl; return tmpl;
} }