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/wait.h>
#include <unistd.h>
#include <ftw.h>
#ifdef __GLIBC__
#include <malloc.h>
#endif
@ -138,15 +139,15 @@ static int nftwCallback(const char *name, const struct stat * /*unused*/,
return 0;
}
void RemoveDirectoryRecursive(const AbsolutePath &path) {
void RemoveDirectoryRecursive(const std::string &path) {
// 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";
if(!mkdtemp(tmpl)) {
return nullopt;
return std::nullopt;
}
return tmpl;
}