Add File::Open / Create functions to take an rtc::Pathname
When implementing ISOLATED_OUTDIR feature in WebRTC, I found two issues,
1. pathutils and flags are not accessible in testsupport. But both of them are
useful for the feature. Pathname can help to combine path with filename, while
a flag is needed to handle command line parameter.
2. rtc::File cannot accept an rtc::Pathname, which is a little bit inconvenient.
After investigating bug webrtc:3806, flags, pathutils and urlencode are
removed from rtc_base_approved because of the including of common.h. So I
replaced common.h with checks.h, and ASSERT with RTC_DCHECK. flags,
pathutils and urlencode pairs now can be placed into rtc_base_approved to
unblock file.h to include pathutils.h.
Please kindly let me know if you have other concerns about this change.
BUG=webrtc:3806, webrtc:6732
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng;master.tryserver.chromium.mac:mac_chromium_rel_ng;master.tryserver.chromium.win:win_chromium_rel_ng;master.tryserver.chromium.android:linux_android_rel_ng
Review-Url: https://codereview.webrtc.org/2533213005
Cr-Commit-Position: refs/heads/master@{#15451}
diff --git a/webrtc/base/pathutils.h b/webrtc/base/pathutils.h
index 2a0efa9..5a5fd1e 100644
--- a/webrtc/base/pathutils.h
+++ b/webrtc/base/pathutils.h
@@ -12,8 +12,8 @@
#define WEBRTC_BASE_PATHUTILS_H__
#include <string>
-// Temporary, until deprecated helpers are removed.
-#include "webrtc/base/fileutils.h"
+
+#include "webrtc/base/checks.h"
namespace rtc {
@@ -108,63 +108,6 @@
char folder_delimiter_;
};
-///////////////////////////////////////////////////////////////////////////////
-// Global Helpers (deprecated)
-///////////////////////////////////////////////////////////////////////////////
-
-inline void SetOrganizationName(const std::string& organization) {
- Filesystem::SetOrganizationName(organization);
-}
-inline void SetApplicationName(const std::string& application) {
- Filesystem::SetApplicationName(application);
-}
-inline void GetOrganizationName(std::string* organization) {
- Filesystem::GetOrganizationName(organization);
-}
-inline void GetApplicationName(std::string* application) {
- Filesystem::GetApplicationName(application);
-}
-inline bool CreateFolder(const Pathname& path) {
- return Filesystem::CreateFolder(path);
-}
-inline bool FinishPath(Pathname& path, bool create, const std::string& append) {
- if (!append.empty())
- path.AppendFolder(append);
- return !create || CreateFolder(path);
-}
-// Note: this method uses the convention of <temp>/<appname> for the temporary
-// folder. Filesystem uses <temp>/<exename>. We will be migrating exclusively
-// to <temp>/<orgname>/<appname> eventually. Since these are temp folders,
-// it's probably ok to orphan them during the transition.
-inline bool GetTemporaryFolder(Pathname& path, bool create,
- const std::string& append) {
- std::string application_name;
- Filesystem::GetApplicationName(&application_name);
- ASSERT(!application_name.empty());
- return Filesystem::GetTemporaryFolder(path, create, &application_name)
- && FinishPath(path, create, append);
-}
-inline bool GetAppDataFolder(Pathname& path, bool create,
- const std::string& append) {
- ASSERT(!create); // TODO: Support create flag on Filesystem::GetAppDataFolder.
- return Filesystem::GetAppDataFolder(&path, true)
- && FinishPath(path, create, append);
-}
-inline bool CleanupTemporaryFolder() {
- Pathname path;
- if (!GetTemporaryFolder(path, false, ""))
- return false;
- if (Filesystem::IsAbsent(path))
- return true;
- if (!Filesystem::IsTemporaryPath(path)) {
- ASSERT(false);
- return false;
- }
- return Filesystem::DeleteFolderContents(path);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
} // namespace rtc
#endif // WEBRTC_BASE_PATHUTILS_H__