Loading base/file.cpp +32 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <errno.h> #include <fcntl.h> #include <ftw.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> Loading @@ -30,11 +31,6 @@ #include <string> #include <vector> #include "android-base/logging.h" #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. #include "android-base/unique_fd.h" #include "android-base/utf8.h" #if defined(__APPLE__) #include <mach-o/dyld.h> #endif Loading @@ -47,6 +43,11 @@ #define OS_PATH_SEPARATOR '/' #endif #include "android-base/logging.h" // and must be after windows.h for ERROR #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. #include "android-base/unique_fd.h" #include "android-base/utf8.h" #ifdef _WIN32 int mkstemp(char* template_name) { if (_mktemp(template_name) == nullptr) { Loading Loading @@ -133,7 +134,32 @@ TemporaryDir::TemporaryDir() { } TemporaryDir::~TemporaryDir() { rmdir(path); auto callback = [](const char* child, const struct stat*, int file_type, struct FTW*) -> int { switch (file_type) { case FTW_D: case FTW_DP: case FTW_DNR: if (rmdir(child) == -1) { PLOG(ERROR) << "rmdir " << child; } break; case FTW_NS: default: if (rmdir(child) != -1) break; // FALLTHRU (for gcc, lint, pcc, etc; and following for clang) FALLTHROUGH_INTENDED; case FTW_F: case FTW_SL: case FTW_SLN: if (unlink(child) == -1) { PLOG(ERROR) << "unlink " << child; } break; } return 0; }; nftw(path, callback, 128, FTW_DEPTH | FTW_MOUNT | FTW_PHYS); } bool TemporaryDir::init(const std::string& tmp_dir) { Loading Loading
base/file.cpp +32 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <errno.h> #include <fcntl.h> #include <ftw.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> Loading @@ -30,11 +31,6 @@ #include <string> #include <vector> #include "android-base/logging.h" #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. #include "android-base/unique_fd.h" #include "android-base/utf8.h" #if defined(__APPLE__) #include <mach-o/dyld.h> #endif Loading @@ -47,6 +43,11 @@ #define OS_PATH_SEPARATOR '/' #endif #include "android-base/logging.h" // and must be after windows.h for ERROR #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. #include "android-base/unique_fd.h" #include "android-base/utf8.h" #ifdef _WIN32 int mkstemp(char* template_name) { if (_mktemp(template_name) == nullptr) { Loading Loading @@ -133,7 +134,32 @@ TemporaryDir::TemporaryDir() { } TemporaryDir::~TemporaryDir() { rmdir(path); auto callback = [](const char* child, const struct stat*, int file_type, struct FTW*) -> int { switch (file_type) { case FTW_D: case FTW_DP: case FTW_DNR: if (rmdir(child) == -1) { PLOG(ERROR) << "rmdir " << child; } break; case FTW_NS: default: if (rmdir(child) != -1) break; // FALLTHRU (for gcc, lint, pcc, etc; and following for clang) FALLTHROUGH_INTENDED; case FTW_F: case FTW_SL: case FTW_SLN: if (unlink(child) == -1) { PLOG(ERROR) << "unlink " << child; } break; } return 0; }; nftw(path, callback, 128, FTW_DEPTH | FTW_MOUNT | FTW_PHYS); } bool TemporaryDir::init(const std::string& tmp_dir) { Loading