File tree Expand file tree Collapse file tree 1 file changed +13
-19
lines changed
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/utils Expand file tree Collapse file tree 1 file changed +13
-19
lines changed Original file line number Diff line number Diff line change 1616 * limitations under the License.
1717 */
1818
19+ #include < filesystem>
20+ #include < iostream>
1921#include < string>
22+ #include < system_error>
2023#include < vector>
2124
22- #include < ftw.h>
2325#include < gtest/gtest.h>
24- #include < sys/stat.h>
2526
2627#include " utils/temp-dir.h"
2728#include " x-platform/syscall.h"
2829
2930namespace TestUtils {
30- /*
31- * Callback to remove a directory in the nftw visitor.
32- */
33- int nftw_remove (const char *fpath, const struct stat *sb, int typeflag,
34- struct FTW *ftwbuf);
35-
3631TempDir::TempDir () {
3732 std::vector path_pattern (path_.begin (), path_.end ());
3833 is_path_init_ = XPlatform::Syscall::CreateTempDir (path_pattern);
@@ -57,19 +52,18 @@ TempDir &TempDir::operator=(TempDir &&other) noexcept {
5752}
5853
5954TempDir::~TempDir () {
60- if (is_path_init_) {
61- nftw (path_. c_str (), nftw_remove, 64 , FTW_DEPTH | FTW_PHYS) ;
55+ if (! is_path_init_) {
56+ return ;
6257 }
63- }
6458
65- int nftw_remove (const char *fpath, const struct stat *sb, int typeflag,
66- FTW *ftwbuf) {
67- (void )sb;
68- (void )typeflag;
69- (void )ftwbuf;
59+ const std::filesystem::path tmp_dir_path (path_);
60+ std::error_code tmp_dir_rm_err;
7061
71- int rv = remove (fpath);
72- EXPECT_EQ (0 , rv);
73- return rv;
62+ const auto tmp_dir_rm_result = remove_all (tmp_dir_path, tmp_dir_rm_err);
63+ EXPECT_TRUE (tmp_dir_rm_result);
64+ if (!tmp_dir_rm_result) {
65+ std::cerr << " Error in deleting directory " << path_ << " : "
66+ << tmp_dir_rm_err.message () << std::endl;
67+ }
7468}
7569} // namespace TestUtils
You can’t perform that action at this time.
0 commit comments