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.h b/rtc_base/fileutils.h
index d85b6b1..deaf2e3 100644
--- a/rtc_base/fileutils.h
+++ b/rtc_base/fileutils.h
@@ -25,6 +25,8 @@
namespace rtc {
+class Pathname;
+
//////////////////////////
// Directory Iterator //
//////////////////////////
@@ -42,25 +44,22 @@
// Destructor
virtual ~DirectoryIterator();
- // Starts traversing a directory.
- // |dir| is the directory to traverse.
- // returns true if the directory exists and is valid.
- // The iterator will point to the first entry in the directory.
- virtual bool Iterate(const std::string& dir);
+ // Starts traversing a directory
+ // dir is the directory to traverse
+ // returns true if the directory exists and is valid
+ // The iterator will point to the first entry in the directory
+ virtual bool Iterate(const Pathname& path);
// Advances to the next file
// returns true if there were more files in the directory.
virtual bool Next();
- // Returns true if the file currently pointed to is a directory.
+ // returns true if the file currently pointed to is a directory
virtual bool IsDirectory() const;
- // Returns the name of the file currently pointed to.
+ // returns the name of the file currently pointed to
virtual std::string Name() const;
- // Returns complete name of the file, including directory part.
- virtual std::string PathName() const;
-
private:
std::string directory_;
#if defined(WEBRTC_WIN)
@@ -80,37 +79,42 @@
// This will attempt to delete the path located at filename.
// It DCHECKs and returns false if the path points to a folder or a
// non-existent file.
- virtual bool DeleteFile(const std::string& filename) = 0;
+ virtual bool DeleteFile(const Pathname& filename) = 0;
// This moves a file from old_path to new_path, where "old_path" is a
// plain file. This DCHECKs and returns false if old_path points to a
// directory, and returns true if the function succeeds.
- virtual bool MoveFile(const std::string& old_path,
- const std::string& new_path) = 0;
+ virtual bool MoveFile(const Pathname& old_path, const Pathname& new_path) = 0;
+
+ // Returns true if pathname refers to a directory
+ virtual bool IsFolder(const Pathname& pathname) = 0;
// Returns true if pathname refers to a file
- virtual bool IsFile(const std::string& pathname) = 0;
+ virtual bool IsFile(const Pathname& pathname) = 0;
// Determines the size of the file indicated by path.
- virtual bool GetFileSize(const std::string& path, size_t* size) = 0;
+ virtual bool GetFileSize(const Pathname& path, size_t* size) = 0;
};
class Filesystem {
public:
- static bool DeleteFile(const std::string& filename) {
+ static bool DeleteFile(const Pathname& filename) {
return GetFilesystem()->DeleteFile(filename);
}
- static bool MoveFile(const std::string& old_path,
- const std::string& new_path) {
+ static bool MoveFile(const Pathname& old_path, const Pathname& new_path) {
return GetFilesystem()->MoveFile(old_path, new_path);
}
- static bool IsFile(const std::string& pathname) {
+ static bool IsFolder(const Pathname& pathname) {
+ return GetFilesystem()->IsFolder(pathname);
+ }
+
+ static bool IsFile(const Pathname& pathname) {
return GetFilesystem()->IsFile(pathname);
}
- static bool GetFileSize(const std::string& path, size_t* size) {
+ static bool GetFileSize(const Pathname& path, size_t* size) {
return GetFilesystem()->GetFileSize(path, size);
}