Delete unused methods on rtc::Pathname.

Deleted methods Normalize(), clear(), empty(), folder(), parent_folder().

Bug: webrtc:6424
Change-Id: I7a7096b23f4ba675305de1728988d2cfb48f135f
Reviewed-on: https://webrtc-review.googlesource.com/80520
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23623}
This commit is contained in:
Niels Möller
2018-06-01 14:08:25 +02:00
committed by Commit Bot
parent 65c61dcfce
commit 394b4ebe38
4 changed files with 3 additions and 57 deletions

View File

@ -195,10 +195,10 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteOverflowAndRead) {
// Tests that the returned file paths have the right folder and prefix.
TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) {
Init("FileRotatingStreamTestGetFilePath", kFilePrefix, kMaxFileSize, 20);
// dir_path_ includes a trailing delimiter.
const std::string prefix = dir_path_ + kFilePrefix;
for (auto i = 0; i < 20; ++i) {
Pathname path(stream_->GetFilePath(i));
EXPECT_EQ(0, path.folder().compare(dir_path_));
EXPECT_EQ(0, path.filename().compare(0, strlen(kFilePrefix), kFilePrefix));
EXPECT_EQ(0, stream_->GetFilePath(i).compare(0, prefix.size(), prefix));
}
}

View File

@ -69,24 +69,6 @@ Pathname::Pathname(const std::string& folder, const std::string& filename)
Pathname& Pathname::operator=(const Pathname&) = default;
Pathname& Pathname::operator=(Pathname&&) = default;
void Pathname::Normalize() {
for (size_t i=0; i<folder_.length(); ++i) {
if (IsFolderDelimiter(folder_[i])) {
folder_[i] = folder_delimiter_;
}
}
}
void Pathname::clear() {
folder_.clear();
basename_.clear();
extension_.clear();
}
bool Pathname::empty() const {
return folder_.empty() && basename_.empty() && extension_.empty();
}
std::string Pathname::pathname() const {
std::string pathname(folder_);
pathname.append(basename_);
@ -116,22 +98,6 @@ void Pathname::SetPathname(const std::string& folder,
SetFilename(filename);
}
std::string Pathname::folder() const {
return folder_;
}
std::string Pathname::parent_folder() const {
std::string::size_type pos = std::string::npos;
if (folder_.size() >= 2) {
pos = folder_.find_last_of(FOLDER_DELIMS, folder_.length() - 2);
}
if (pos != std::string::npos) {
return folder_.substr(0, pos + 1);
} else {
return EMPTY_STR;
}
}
void Pathname::SetFolder(const std::string& folder) {
folder_.assign(folder);
// Ensure folder ends in a path delimiter

View File

@ -52,16 +52,6 @@ public:
Pathname& operator=(const Pathname&);
Pathname& operator=(Pathname&&);
// Normalize changes all folder delimiters to folder_delimiter()
void Normalize();
// Reset to the empty pathname
void clear();
// Returns true if the pathname is empty. Note: this->pathname().empty()
// is always false.
bool empty() const;
// Returns the folder and filename components. If the pathname is empty,
// returns a string representing the current directory (as a relative path,
// i.e., ".").
@ -69,8 +59,6 @@ public:
void SetPathname(const std::string& pathname);
void SetPathname(const std::string& folder, const std::string& filename);
std::string folder() const;
std::string parent_folder() const;
// SetFolder and AppendFolder will append a folder delimiter, if needed.
void SetFolder(const std::string& folder);
void AppendFolder(const std::string& folder);

View File

@ -16,29 +16,21 @@ TEST(Pathname, ReturnsDotForEmptyPathname) {
std::string(".") + rtc::Pathname::DefaultFolderDelimiter();
rtc::Pathname path("/", "");
EXPECT_FALSE(path.empty());
EXPECT_FALSE(path.folder().empty());
EXPECT_TRUE (path.filename().empty());
EXPECT_FALSE(path.pathname().empty());
EXPECT_EQ(std::string("/"), path.pathname());
path.SetPathname("", "foo");
EXPECT_FALSE(path.empty());
EXPECT_TRUE (path.folder().empty());
EXPECT_FALSE(path.filename().empty());
EXPECT_FALSE(path.pathname().empty());
EXPECT_EQ(std::string("foo"), path.pathname());
path.SetPathname("", "");
EXPECT_TRUE (path.empty());
EXPECT_TRUE (path.folder().empty());
EXPECT_TRUE (path.filename().empty());
EXPECT_FALSE(path.pathname().empty());
EXPECT_EQ(kCWD, path.pathname());
path.SetPathname(kCWD, "");
EXPECT_FALSE(path.empty());
EXPECT_FALSE(path.folder().empty());
EXPECT_TRUE (path.filename().empty());
EXPECT_FALSE(path.pathname().empty());
EXPECT_EQ(kCWD, path.pathname());