Reland of reduce dependencies on rtc::FileSystem in FileRotatingStream tests... (patchset #1 id:1 of https://codereview.webrtc.org/2885393002/ )
Reason for revert:
Downstream project now fixed.
Original issue's description:
> Revert of Reduce dependencies on rtc::FileSystem in FileRotatingStream tests, adding helpers in webrtc::test:: (patchset #7 id:120001 of https://codereview.webrtc.org/2872283002/ )
>
> Reason for revert:
> Fails to compile successfully.
>
>
> Original issue's description:
> > Reduce dependencies on rtc::FileSystem in FileRotatingStream tests.
> >
> > Use webrtc::test::OutputPath instead of Filesystem::GetAppTempFolder.
> > Added functions RemoveFile and RemoveDir in the webrtc::test namespace,
> > to replace use of Filesystem::DeleteFolderAndContents.
> >
> > This makes Filesystem::DeleteFolderAndContents unused, to be deleted
> > together with related code in a followup cl.
> >
> > BUG=webrtc:7345
> >
> > Review-Url: https://codereview.webrtc.org/2872283002
> > Cr-Commit-Position: refs/heads/master@{#18173}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/dd7b5f32b59d9def668b9e9487589a572f20f6e0
>
> TBR=pthatcher@webrtc.org,kjellander@webrtc.org,tommi@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7345
>
> Review-Url: https://codereview.webrtc.org/2885393002
> Cr-Commit-Position: refs/heads/master@{#18180}
> Committed: https://chromium.googlesource.com/external/webrtc/+/deaa33d2f59783e849ddc01428be807d92431983
TBR=pthatcher@webrtc.org,kjellander@webrtc.org,tommi@webrtc.org,ehmaldonado@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7345
Review-Url: https://codereview.webrtc.org/2885413002
Cr-Commit-Position: refs/heads/master@{#18193}
diff --git a/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc
index 899bf31..02ef065 100644
--- a/webrtc/test/testsupport/fileutils.cc
+++ b/webrtc/test/testsupport/fileutils.cc
@@ -232,6 +232,22 @@
return true;
}
+bool RemoveDir(const std::string& directory_name) {
+#ifdef WIN32
+ return RemoveDirectoryA(directory_name.c_str()) != FALSE;
+#else
+ return rmdir(directory_name.c_str()) == 0;
+#endif
+}
+
+bool RemoveFile(const std::string& file_name) {
+#ifdef WIN32
+ return DeleteFileA(file_name.c_str()) != FALSE;
+#else
+ return unlink(file_name.c_str()) == 0;
+#endif
+}
+
std::string ResourcePath(const std::string& name,
const std::string& extension) {
#if defined(WEBRTC_IOS)
diff --git a/webrtc/test/testsupport/fileutils.h b/webrtc/test/testsupport/fileutils.h
index 549f96b..2135681 100644
--- a/webrtc/test/testsupport/fileutils.h
+++ b/webrtc/test/testsupport/fileutils.h
@@ -71,6 +71,12 @@
// false if a file with the same name already exists.
bool CreateDir(const std::string& directory_name);
+// Removes a directory, which must already be empty.
+bool RemoveDir(const std::string& directory_name);
+
+// Removes a file.
+bool RemoveFile(const std::string& file_name);
+
// Checks if a file exists.
bool FileExists(const std::string& file_name);