diff options
Diffstat (limited to 'SwifTools/Application')
-rw-r--r-- | SwifTools/Application/ApplicationPathProvider.cpp | 46 | ||||
-rw-r--r-- | SwifTools/Application/ApplicationPathProvider.h | 45 | ||||
-rw-r--r-- | SwifTools/Application/CocoaApplication.h | 24 | ||||
-rw-r--r-- | SwifTools/Application/CocoaApplication.mm | 20 | ||||
-rw-r--r-- | SwifTools/Application/MacOSXApplicationPathProvider.cpp | 31 | ||||
-rw-r--r-- | SwifTools/Application/MacOSXApplicationPathProvider.h | 28 | ||||
-rw-r--r-- | SwifTools/Application/PlatformApplicationPathProvider.h | 12 | ||||
-rw-r--r-- | SwifTools/Application/SConscript | 30 | ||||
-rw-r--r-- | SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp | 75 | ||||
-rw-r--r-- | SwifTools/Application/UnixApplicationPathProvider.cpp | 80 | ||||
-rw-r--r-- | SwifTools/Application/UnixApplicationPathProvider.h | 28 | ||||
-rw-r--r-- | SwifTools/Application/WindowsApplicationPathProvider.cpp | 34 | ||||
-rw-r--r-- | SwifTools/Application/WindowsApplicationPathProvider.h | 28 |
13 files changed, 248 insertions, 233 deletions
diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp index aa7e609..77457ef 100644 --- a/SwifTools/Application/ApplicationPathProvider.cpp +++ b/SwifTools/Application/ApplicationPathProvider.cpp @@ -1,14 +1,14 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2019 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ +#include <SwifTools/Application/ApplicationPathProvider.h> + #include <boost/filesystem.hpp> -#include <iostream> -#include <SwifTools/Application/ApplicationPathProvider.h> -#include <Swiften/Base/foreach.h> +#include <Swiften/Base/Log.h> #include <Swiften/Base/Paths.h> namespace Swift { @@ -20,29 +20,29 @@ ApplicationPathProvider::~ApplicationPathProvider() { } boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string& profile) const { - boost::filesystem::path result(getHomeDir() / profile); - try { - boost::filesystem::create_directory(result); - } - catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; - } - return result; + boost::filesystem::path result(getHomeDir() / profile); + try { + boost::filesystem::create_directory(result); + } + catch (const boost::filesystem::filesystem_error& e) { + SWIFT_LOG(error) << e.what(); + } + return result; } boost::filesystem::path ApplicationPathProvider::getResourcePath(const std::string& resource) const { - std::vector<boost::filesystem::path> resourcePaths = getResourceDirs(); - foreach(const boost::filesystem::path& resourcePath, resourcePaths) { - boost::filesystem::path r(resourcePath / resource); - if (boost::filesystem::exists(r)) { - return r; - } - } - return boost::filesystem::path(); + std::vector<boost::filesystem::path> resourcePaths = getResourceDirs(); + for (const auto& resourcePath : resourcePaths) { + boost::filesystem::path r(resourcePath / resource); + if (boost::filesystem::exists(r)) { + return r; + } + } + return boost::filesystem::path(); } boost::filesystem::path ApplicationPathProvider::getExecutableDir() const { - return Paths::getExecutablePath(); + return Paths::getExecutablePath(); } } diff --git a/SwifTools/Application/ApplicationPathProvider.h b/SwifTools/Application/ApplicationPathProvider.h index d5beb8d..399ac5d 100644 --- a/SwifTools/Application/ApplicationPathProvider.h +++ b/SwifTools/Application/ApplicationPathProvider.h @@ -1,34 +1,35 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once -#include <boost/filesystem.hpp> -#include <vector> #include <string> +#include <vector> + +#include <boost/filesystem.hpp> namespace Swift { - class ApplicationPathProvider { - public: - ApplicationPathProvider(const std::string& applicationName); - virtual ~ApplicationPathProvider(); + class ApplicationPathProvider { + public: + ApplicationPathProvider(const std::string& applicationName); + virtual ~ApplicationPathProvider(); - virtual boost::filesystem::path getHomeDir() const = 0; - virtual boost::filesystem::path getDataDir() const = 0; - virtual boost::filesystem::path getExecutableDir() const; - boost::filesystem::path getProfileDir(const std::string& profile) const; - boost::filesystem::path getResourcePath(const std::string& resource) const; + virtual boost::filesystem::path getHomeDir() const = 0; + virtual boost::filesystem::path getDataDir() const = 0; + boost::filesystem::path getExecutableDir() const; + boost::filesystem::path getProfileDir(const std::string& profile) const; + boost::filesystem::path getResourcePath(const std::string& resource) const; - protected: - virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0; - const std::string& getApplicationName() const { - return applicationName; - } + protected: + virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0; + const std::string& getApplicationName() const { + return applicationName; + } - private: - std::string applicationName; - }; + private: + std::string applicationName; + }; } diff --git a/SwifTools/Application/CocoaApplication.h b/SwifTools/Application/CocoaApplication.h index 3b19d28..4b366c6 100644 --- a/SwifTools/Application/CocoaApplication.h +++ b/SwifTools/Application/CocoaApplication.h @@ -1,19 +1,21 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once +#include <memory> + namespace Swift { - class CocoaApplication { - public: - CocoaApplication(); - ~CocoaApplication(); + class CocoaApplication { + public: + CocoaApplication(); + ~CocoaApplication(); - private: - class Private; - Private* d; - }; + private: + class Private; + const std::unique_ptr<Private> d; + }; } diff --git a/SwifTools/Application/CocoaApplication.mm b/SwifTools/Application/CocoaApplication.mm index cbb5f2e..f058ed4 100644 --- a/SwifTools/Application/CocoaApplication.mm +++ b/SwifTools/Application/CocoaApplication.mm @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2010-2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include <SwifTools/Application/CocoaApplication.h> #include <AppKit/AppKit.h> @@ -6,19 +12,17 @@ namespace Swift { class CocoaApplication::Private { - public: - NSAutoreleasePool* autoReleasePool_; + public: + NSAutoreleasePool* autoReleasePool_; }; -CocoaApplication::CocoaApplication() { - d = new CocoaApplication::Private(); - NSApplicationLoad(); - d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; +CocoaApplication::CocoaApplication() : d(new Private()) { + NSApplicationLoad(); + d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; } CocoaApplication::~CocoaApplication() { - [d->autoReleasePool_ release]; - delete d; + [d->autoReleasePool_ release]; } } diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp index 41b0e4c..d7b99b9 100644 --- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp +++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp @@ -1,34 +1,35 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2019 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <SwifTools/Application/MacOSXApplicationPathProvider.h> -#include <iostream> #include <mach-o/dyld.h> +#include <Swiften/Base/Log.h> + namespace Swift { MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { - resourceDirs.push_back(getExecutableDir() / "../Resources"); - resourceDirs.push_back(getExecutableDir() / "../resources"); // Development + resourceDirs.push_back(getExecutableDir() / "../Resources"); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const { - boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName()); - try { - boost::filesystem::create_directory(result); - } - catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; - } - return result; + boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName()); + try { + boost::filesystem::create_directory(result); + } + catch (const boost::filesystem::filesystem_error& e) { + SWIFT_LOG(error) << e.what(); + } + return result; } boost::filesystem::path MacOSXApplicationPathProvider::getHomeDir() const { - return boost::filesystem::path(getenv("HOME")); + return boost::filesystem::path(getenv("HOME")); } } diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.h b/SwifTools/Application/MacOSXApplicationPathProvider.h index 760ea9b..9d8f619 100644 --- a/SwifTools/Application/MacOSXApplicationPathProvider.h +++ b/SwifTools/Application/MacOSXApplicationPathProvider.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once @@ -9,18 +9,18 @@ #include <SwifTools/Application/ApplicationPathProvider.h> namespace Swift { - class MacOSXApplicationPathProvider : public ApplicationPathProvider { - public: - MacOSXApplicationPathProvider(const std::string& name); + class MacOSXApplicationPathProvider : public ApplicationPathProvider { + public: + MacOSXApplicationPathProvider(const std::string& name); - virtual boost::filesystem::path getHomeDir() const; - boost::filesystem::path getDataDir() const; + virtual boost::filesystem::path getHomeDir() const; + boost::filesystem::path getDataDir() const; - virtual std::vector<boost::filesystem::path> getResourceDirs() const { - return resourceDirs; - } + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } - private: - std::vector<boost::filesystem::path> resourceDirs; - }; + private: + std::vector<boost::filesystem::path> resourceDirs; + }; } diff --git a/SwifTools/Application/PlatformApplicationPathProvider.h b/SwifTools/Application/PlatformApplicationPathProvider.h index 7ea4b35..5de91fe 100644 --- a/SwifTools/Application/PlatformApplicationPathProvider.h +++ b/SwifTools/Application/PlatformApplicationPathProvider.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once @@ -11,16 +11,16 @@ #if defined(SWIFTEN_PLATFORM_MACOSX) #include <SwifTools/Application/MacOSXApplicationPathProvider.h> namespace Swift { - typedef MacOSXApplicationPathProvider PlatformApplicationPathProvider; + typedef MacOSXApplicationPathProvider PlatformApplicationPathProvider; } #elif defined(SWIFTEN_PLATFORM_WIN32) #include <SwifTools/Application/WindowsApplicationPathProvider.h> namespace Swift { - typedef WindowsApplicationPathProvider PlatformApplicationPathProvider; + typedef WindowsApplicationPathProvider PlatformApplicationPathProvider; } #else #include <SwifTools/Application/UnixApplicationPathProvider.h> namespace Swift { - typedef UnixApplicationPathProvider PlatformApplicationPathProvider; + typedef UnixApplicationPathProvider PlatformApplicationPathProvider; } #endif diff --git a/SwifTools/Application/SConscript b/SwifTools/Application/SConscript index 32924fc..29bcceb 100644 --- a/SwifTools/Application/SConscript +++ b/SwifTools/Application/SConscript @@ -1,27 +1,27 @@ Import("swiftools_env", "env") sources = [ - "ApplicationPathProvider.cpp", - ] + "ApplicationPathProvider.cpp", + ] if swiftools_env["PLATFORM"] == "darwin" and swiftools_env["target"] == "native" : - sources += [ - "CocoaApplication.mm", - "MacOSXApplicationPathProvider.cpp", - ] + sources += [ + "CocoaApplication.mm", + "MacOSXApplicationPathProvider.cpp", + ] elif swiftools_env["PLATFORM"] == "win32" : - sources += [ - "WindowsApplicationPathProvider.cpp" - ] + sources += [ + "WindowsApplicationPathProvider.cpp" + ] else : - sources += [ - "UnixApplicationPathProvider.cpp" - ] + sources += [ + "UnixApplicationPathProvider.cpp" + ] objects = swiftools_env.StaticObject(sources) swiftools_env.Append(SWIFTOOLS_OBJECTS = [objects]) if swiftools_env["PLATFORM"] != "darwin" or swiftools_env["target"] == "native" : - env.Append(UNITTEST_SOURCES = [ - File("UnitTest/ApplicationPathProviderTest.cpp") - ]) + env.Append(UNITTEST_SOURCES = [ + File("UnitTest/ApplicationPathProviderTest.cpp") + ]) diff --git a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp index e7a47a7..433b379 100644 --- a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp +++ b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp @@ -1,51 +1,54 @@ /* - * Copyright (c) 2010-2013 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> #include <string> + #include <boost/algorithm/string.hpp> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + #include <Swiften/Base/Path.h> + #include <SwifTools/Application/PlatformApplicationPathProvider.h> using namespace Swift; class ApplicationPathProviderTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(ApplicationPathProviderTest); - CPPUNIT_TEST(testGetDataDir); - CPPUNIT_TEST(testGetExecutableDir); - CPPUNIT_TEST_SUITE_END(); - - public: - void setUp() { - testling_ = new PlatformApplicationPathProvider("SwiftTest"); - } - - void tearDown() { - delete testling_; - } - - void testGetDataDir() { - boost::filesystem::path dir = testling_->getDataDir(); - - CPPUNIT_ASSERT(boost::filesystem::exists(dir)); - CPPUNIT_ASSERT(boost::filesystem::is_directory(dir)); - - boost::filesystem::remove(dir); - } - - void testGetExecutableDir() { - boost::filesystem::path dir = testling_->getExecutableDir(); - CPPUNIT_ASSERT(boost::filesystem::is_directory(dir)); - CPPUNIT_ASSERT(boost::ends_with(pathToString(dir), "UnitTest")); - } - - private: - ApplicationPathProvider* testling_; + CPPUNIT_TEST_SUITE(ApplicationPathProviderTest); + CPPUNIT_TEST(testGetDataDir); + CPPUNIT_TEST(testGetExecutableDir); + CPPUNIT_TEST_SUITE_END(); + + public: + void setUp() { + testling_ = new PlatformApplicationPathProvider("SwiftTest"); + } + + void tearDown() { + delete testling_; + } + + void testGetDataDir() { + boost::filesystem::path dir = testling_->getDataDir(); + + CPPUNIT_ASSERT(boost::filesystem::exists(dir)); + CPPUNIT_ASSERT(boost::filesystem::is_directory(dir)); + + boost::filesystem::remove(dir); + } + + void testGetExecutableDir() { + boost::filesystem::path dir = testling_->getExecutableDir(); + CPPUNIT_ASSERT(boost::filesystem::is_directory(dir)); + CPPUNIT_ASSERT(boost::ends_with(pathToString(dir), "UnitTest")); + } + + private: + ApplicationPathProvider* testling_; }; CPPUNIT_TEST_SUITE_REGISTRATION(ApplicationPathProviderTest); diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp index 784256f..a345766 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.cpp +++ b/SwifTools/Application/UnixApplicationPathProvider.cpp @@ -1,60 +1,62 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2019 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <SwifTools/Application/UnixApplicationPathProvider.h> -#include <unistd.h> +#include <stdlib.h> + #include <boost/algorithm/string.hpp> -#include <iostream> +#include <unistd.h> + +#include <Swiften/Base/Log.h> #include <Swiften/Base/String.h> -#include <Swiften/Base/foreach.h> namespace Swift { UnixApplicationPathProvider::UnixApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { - resourceDirs.push_back(getExecutableDir() / "../resources"); // Development - resourceDirs.push_back(getExecutableDir() / ".." / "share" / boost::to_lower_copy(getApplicationName())); // Local install - char* xdgDataDirs = getenv("XDG_DATA_DIRS"); - if (xdgDataDirs) { - std::vector<std::string> dataDirs = String::split(xdgDataDirs, ':'); - if (!dataDirs.empty()) { - foreach(const std::string& dir, dataDirs) { - resourceDirs.push_back(boost::filesystem::path(dir) / "swift"); - } - return; - } - } - resourceDirs.push_back("/usr/local/share/" + boost::to_lower_copy(getApplicationName())); - resourceDirs.push_back("/usr/share/" + boost::to_lower_copy(getApplicationName())); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development + resourceDirs.push_back(getExecutableDir() / ".." / "share" / boost::to_lower_copy(getApplicationName())); // Local install + char* xdgDataDirs = getenv("XDG_DATA_DIRS"); + if (xdgDataDirs) { + std::vector<std::string> dataDirs = String::split(xdgDataDirs, ':'); + if (!dataDirs.empty()) { + for (const auto& dir : dataDirs) { + resourceDirs.push_back(boost::filesystem::path(dir) / "swift"); + } + return; + } + } + resourceDirs.push_back("/usr/local/share/" + boost::to_lower_copy(getApplicationName())); + resourceDirs.push_back("/usr/share/" + boost::to_lower_copy(getApplicationName())); } boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const { - char* home = getenv("HOME"); - return home ? boost::filesystem::path(home) : boost::filesystem::path(); + char* home = getenv("HOME"); + return home ? boost::filesystem::path(home) : boost::filesystem::path(); } boost::filesystem::path UnixApplicationPathProvider::getDataDir() const { - char* xdgDataHome = getenv("XDG_DATA_HOME"); - std::string dataDir; - if (xdgDataHome) { - dataDir = std::string(xdgDataHome); - } - - boost::filesystem::path dataPath = (dataDir.empty() ? - getHomeDir() / ".local" / "share" - : boost::filesystem::path(dataDir)) / boost::to_lower_copy(getApplicationName()); - - try { - boost::filesystem::create_directories(dataPath); - } - catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; - } - return dataPath; + char* xdgDataHome = getenv("XDG_DATA_HOME"); + std::string dataDir; + if (xdgDataHome) { + dataDir = std::string(xdgDataHome); + } + + boost::filesystem::path dataPath = (dataDir.empty() ? + getHomeDir() / ".local" / "share" + : boost::filesystem::path(dataDir)) / boost::to_lower_copy(getApplicationName()); + + try { + boost::filesystem::create_directories(dataPath); + } + catch (const boost::filesystem::filesystem_error& e) { + SWIFT_LOG(error) << "file system error: " << e.what(); + } + return dataPath; } } diff --git a/SwifTools/Application/UnixApplicationPathProvider.h b/SwifTools/Application/UnixApplicationPathProvider.h index 198e4ee..9e27a93 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.h +++ b/SwifTools/Application/UnixApplicationPathProvider.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once @@ -9,19 +9,19 @@ #include <SwifTools/Application/ApplicationPathProvider.h> namespace Swift { - class UnixApplicationPathProvider : public ApplicationPathProvider { - public: - UnixApplicationPathProvider(const std::string& name); + class UnixApplicationPathProvider : public ApplicationPathProvider { + public: + UnixApplicationPathProvider(const std::string& name); - virtual boost::filesystem::path getHomeDir() const; - boost::filesystem::path getDataDir() const; + virtual boost::filesystem::path getHomeDir() const; + boost::filesystem::path getDataDir() const; - virtual std::vector<boost::filesystem::path> getResourceDirs() const { - return resourceDirs; - } + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } - private: - std::vector<boost::filesystem::path> resourceDirs; - }; + private: + std::vector<boost::filesystem::path> resourceDirs; + }; } diff --git a/SwifTools/Application/WindowsApplicationPathProvider.cpp b/SwifTools/Application/WindowsApplicationPathProvider.cpp index 2c61208..e90214c 100644 --- a/SwifTools/Application/WindowsApplicationPathProvider.cpp +++ b/SwifTools/Application/WindowsApplicationPathProvider.cpp @@ -1,36 +1,38 @@ /* - * Copyright (c) 2010-2013 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010-2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <SwifTools/Application/WindowsApplicationPathProvider.h> -#include <windows.h> #include <cassert> + +#include <windows.h> + #include <Swiften/Base/String.h> namespace Swift { WindowsApplicationPathProvider::WindowsApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) { - resourceDirs.push_back(getExecutableDir()); - resourceDirs.push_back(getExecutableDir() / "../resources"); // Development + resourceDirs.push_back(getExecutableDir()); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } boost::filesystem::path WindowsApplicationPathProvider::getDataDir() const { - wchar_t* appDirRaw = _wgetenv(L"APPDATA"); - assert(appDirRaw); - boost::filesystem::path result( - boost::filesystem::path(appDirRaw) / getApplicationName()); - boost::filesystem::create_directory(result); - return result; + wchar_t* appDirRaw = _wgetenv(L"APPDATA"); + assert(appDirRaw); + boost::filesystem::path result( + boost::filesystem::path(appDirRaw) / getApplicationName()); + boost::filesystem::create_directory(result); + return result; } boost::filesystem::path WindowsApplicationPathProvider::getHomeDir() const { - //FIXME: This should be My Documents - wchar_t* homeDirRaw = _wgetenv(L"USERPROFILE"); - assert(homeDirRaw); - return boost::filesystem::path(homeDirRaw); + //FIXME: This should be My Documents + wchar_t* homeDirRaw = _wgetenv(L"USERPROFILE"); + assert(homeDirRaw); + return boost::filesystem::path(homeDirRaw); } diff --git a/SwifTools/Application/WindowsApplicationPathProvider.h b/SwifTools/Application/WindowsApplicationPathProvider.h index a4e8668..bf8dada 100644 --- a/SwifTools/Application/WindowsApplicationPathProvider.h +++ b/SwifTools/Application/WindowsApplicationPathProvider.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once @@ -9,18 +9,18 @@ #include <SwifTools/Application/ApplicationPathProvider.h> namespace Swift { - class WindowsApplicationPathProvider : public ApplicationPathProvider { - public: - WindowsApplicationPathProvider(const std::string& name); + class WindowsApplicationPathProvider : public ApplicationPathProvider { + public: + WindowsApplicationPathProvider(const std::string& name); - boost::filesystem::path getDataDir() const; - boost::filesystem::path getHomeDir() const; + boost::filesystem::path getDataDir() const; + boost::filesystem::path getHomeDir() const; - virtual std::vector<boost::filesystem::path> getResourceDirs() const { - return resourceDirs; - } + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } - private: - std::vector<boost::filesystem::path> resourceDirs; - }; + private: + std::vector<boost::filesystem::path> resourceDirs; + }; } |