diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-17 19:26:21 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-17 19:26:21 (GMT) |
commit | 6fd3078f8f512c74bfc54c3d31d6446098088a69 (patch) | |
tree | 5db18c9405c83887142d0dc249236cc8d225378e | |
parent | 9e5cc663f5018c03fd2657284dfdd5e522d55cbf (diff) | |
download | swift-contrib-6fd3078f8f512c74bfc54c3d31d6446098088a69.zip swift-contrib-6fd3078f8f512c74bfc54c3d31d6446098088a69.tar.bz2 |
Catch exceptions from create_dir.
-rw-r--r-- | Swiften/Application/Application.cpp | 8 | ||||
-rw-r--r-- | Swiften/Application/MacOSX/MacOSXApplication.cpp | 9 | ||||
-rw-r--r-- | Swiften/Application/Unix/UnixApplication.h | 9 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarFileStorage.cpp | 7 |
4 files changed, 29 insertions, 4 deletions
diff --git a/Swiften/Application/Application.cpp b/Swiften/Application/Application.cpp index 24545cb..d9f4a86 100644 --- a/Swiften/Application/Application.cpp +++ b/Swiften/Application/Application.cpp @@ -6,6 +6,7 @@ #include "Swiften/Application/Application.h" +#include <iostream> #include <boost/filesystem.hpp> #include <stdlib.h> @@ -29,7 +30,12 @@ boost::filesystem::path Application::getAvatarDir() const { boost::filesystem::path Application::getProfileDir(const String& profile) const { boost::filesystem::path result(getHomeDir() / profile.getUTF8String()); - boost::filesystem::create_directory(result); + try { + boost::filesystem::create_directory(result); + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } return result; } diff --git a/Swiften/Application/MacOSX/MacOSXApplication.cpp b/Swiften/Application/MacOSX/MacOSXApplication.cpp index ca73274..8e9a948 100644 --- a/Swiften/Application/MacOSX/MacOSXApplication.cpp +++ b/Swiften/Application/MacOSX/MacOSXApplication.cpp @@ -6,6 +6,8 @@ #include "Swiften/Application/MacOSX/MacOSXApplication.h" +#include <iostream> + namespace Swift { MacOSXApplication::MacOSXApplication(const String& name) : Application(name) { @@ -16,7 +18,12 @@ ApplicationMessageDisplay* MacOSXApplication::getApplicationMessageDisplay() { } boost::filesystem::path MacOSXApplication::getSettingsDir() const { - boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getName().getUTF8String()); + try { + boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getName().getUTF8String()); + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } boost::filesystem::create_directory(result); return result; } diff --git a/Swiften/Application/Unix/UnixApplication.h b/Swiften/Application/Unix/UnixApplication.h index 1c985e8..56ee0ed 100644 --- a/Swiften/Application/Unix/UnixApplication.h +++ b/Swiften/Application/Unix/UnixApplication.h @@ -10,6 +10,8 @@ #include "Swiften/Application/Application.h" #include "Swiften/Application/NullApplicationMessageDisplay.h" +#include <iostream> + namespace Swift { class UnixApplication : public Application { public: @@ -26,7 +28,12 @@ namespace Swift { boost::filesystem::path getSettingsDir() const { boost::filesystem::path result(getHomeDir() / ("." + getName().getLowerCase().getUTF8String())); - boost::filesystem::create_directory(result); + try { + boost::filesystem::create_directory(result); + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } return result; } diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp index c323c0e..a0ebd21 100644 --- a/Swiften/Avatars/AvatarFileStorage.cpp +++ b/Swiften/Avatars/AvatarFileStorage.cpp @@ -12,7 +12,12 @@ namespace Swift { AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& path) : path_(path) { - boost::filesystem::create_directory(path_); + try { + boost::filesystem::create_directory(path_); + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } } bool AvatarFileStorage::hasAvatar(const String& hash) const { |