Revert "Delete rtc::Pathname"
This reverts commit 6b9dec0d16f2df59fa2820c5ec1341be52fb9f32.
Reason for revert: speculative revert for breaking internal projects
Original change's description:
> Delete rtc::Pathname
>
> Bug: webrtc:6424
> Change-Id: Iec01dc5dd1426d4558983b828b67af872107d723
> Reviewed-on: https://webrtc-review.googlesource.com/c/108400
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25479}
TBR=kwiberg@webrtc.org,nisse@webrtc.org
Change-Id: I3129a81a1d8e36b3e6c67572410bdc478ec4d5e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:6424
Reviewed-on: https://webrtc-review.googlesource.com/c/109201
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25490}
diff --git a/rtc_base/fileutils.cc b/rtc_base/fileutils.cc
index 1086f3c..0adbbac 100644
--- a/rtc_base/fileutils.cc
+++ b/rtc_base/fileutils.cc
@@ -11,6 +11,7 @@
#include "rtc_base/fileutils.h"
#include "rtc_base/checks.h"
+#include "rtc_base/pathutils.h"
#if defined(WEBRTC_WIN)
#include "rtc_base/stringutils.h" // for ToUtf16
@@ -57,12 +58,12 @@
// Starts traversing a directory.
// dir is the directory to traverse
// returns true if the directory exists and is valid
-bool DirectoryIterator::Iterate(const std::string& dir) {
- directory_ = dir;
+bool DirectoryIterator::Iterate(const Pathname& dir) {
+ directory_ = dir.pathname();
#if defined(WEBRTC_WIN)
if (handle_ != INVALID_HANDLE_VALUE)
::FindClose(handle_);
- std::string d = dir + '*';
+ std::string d = dir.pathname() + '*';
handle_ = ::FindFirstFile(ToUtf16(d).c_str(), &data_);
if (handle_ == INVALID_HANDLE_VALUE)
return false;
@@ -76,7 +77,7 @@
if (dirent_ == nullptr)
return false;
- if (::stat(PathName().c_str(), &stat_) != 0)
+ if (::stat(std::string(directory_ + Name()).c_str(), &stat_) != 0)
return false;
#endif
return true;
@@ -92,7 +93,7 @@
if (dirent_ == nullptr)
return false;
- return ::stat(PathName().c_str(), &stat_) == 0;
+ return ::stat(std::string(directory_ + Name()).c_str(), &stat_) == 0;
#endif
}
@@ -111,17 +112,7 @@
return ToUtf8(data_.cFileName);
#else
RTC_DCHECK(dirent_);
- return std::string(dirent_->d_name);
-#endif
-}
-
-// returns the name of the file currently pointed to
-std::string DirectoryIterator::PathName() const {
-#if defined(WEBRTC_WIN)
- return directory_ + "\\" + ToUtf8(data_.cFileName);
-#else
- RTC_DCHECK(dirent_);
- return directory_ + "/" + dirent_->d_name;
+ return dirent_->d_name;
#endif
}