diff options
Diffstat (limited to 'src/core/profile_qt.cpp')
-rw-r--r-- | src/core/profile_qt.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 36303605f..ae1169558 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -58,6 +58,7 @@ #include "content/public/browser/storage_partition.h" #include "base/base_paths.h" +#include "base/files/file_util.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/prefs/pref_member.h" #include "components/prefs/pref_service.h" @@ -298,4 +299,21 @@ content::PlatformNotificationService *ProfileQt::platformNotificationService() return m_platformNotificationService.get(); } +bool ProfileQt::ensureDirectoryExists() +{ + const base::FilePath &path = GetPath(); + + if (base::PathExists(path)) + return true; + + base::File::Error error; + if (base::CreateDirectoryAndGetError(path, &error)) + return true; + + std::string errorstr = base::File::ErrorToString(error); + qWarning("Cannot create directory %s. Error: %s.", path.AsUTF8Unsafe().c_str(), + errorstr.c_str()); + return false; +} + } // namespace QtWebEngineCore |