diff --git a/Foundation/include/Poco/Path_WIN32.h b/Foundation/include/Poco/Path_WIN32.h index 5b2c3de32..02a3a5b28 100644 --- a/Foundation/include/Poco/Path_WIN32.h +++ b/Foundation/include/Poco/Path_WIN32.h @@ -33,7 +33,9 @@ public: static std::string configHomeImpl(); static std::string dataHomeImpl(); static std::string cacheHomeImpl(); + static std::string tempHomeImpl(); static std::string tempImpl(); + static std::string configImpl(); static std::string nullImpl(); static std::string systemImpl(); static std::string expandImpl(const std::string& path); diff --git a/Foundation/include/Poco/Path_WIN32U.h b/Foundation/include/Poco/Path_WIN32U.h index 95a4b37b5..94fca2b0a 100644 --- a/Foundation/include/Poco/Path_WIN32U.h +++ b/Foundation/include/Poco/Path_WIN32U.h @@ -33,7 +33,9 @@ public: static std::string configHomeImpl(); static std::string dataHomeImpl(); static std::string cacheHomeImpl(); + static std::string tempHomeImpl(); static std::string tempImpl(); + static std::string configImpl(); static std::string nullImpl(); static std::string systemImpl(); static std::string expandImpl(const std::string& path); diff --git a/Foundation/src/Path.cpp b/Foundation/src/Path.cpp index 135831447..beeefad71 100644 --- a/Foundation/src/Path.cpp +++ b/Foundation/src/Path.cpp @@ -571,7 +571,7 @@ std::string Path::home() std::string Path::configHome() { -#if defined(POCO_OS_FAMILY_UNIX) +#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS) return PathImpl::configHomeImpl(); #else return PathImpl::homeImpl(); @@ -581,7 +581,7 @@ std::string Path::configHome() std::string Path::dataHome() { -#if defined(POCO_OS_FAMILY_UNIX) +#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS) return PathImpl::dataHomeImpl(); #else return PathImpl::homeImpl(); @@ -591,7 +591,7 @@ std::string Path::dataHome() std::string Path::tempHome() { -#if defined(POCO_OS_FAMILY_UNIX) +#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS) return PathImpl::tempHomeImpl(); #else return PathImpl::tempImpl(); @@ -601,7 +601,7 @@ std::string Path::tempHome() std::string Path::cacheHome() { -#if defined(POCO_OS_FAMILY_UNIX) +#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS) return PathImpl::cacheHomeImpl(); #else return PathImpl::homeImpl(); @@ -617,7 +617,7 @@ std::string Path::temp() std::string Path::config() { -#if defined(POCO_OS_FAMILY_UNIX) +#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS) return PathImpl::configImpl(); #else return PathImpl::currentImpl(); diff --git a/Foundation/src/Path_WIN32.cpp b/Foundation/src/Path_WIN32.cpp index 366b6ce12..11e12be88 100644 --- a/Foundation/src/Path_WIN32.cpp +++ b/Foundation/src/Path_WIN32.cpp @@ -122,6 +122,12 @@ std::string PathImpl::cacheHomeImpl() } +std::string PathImpl::tempHomeImpl() +{ + return tempImpl(); +} + + std::string PathImpl::tempImpl() { char buffer[MAX_PATH]; @@ -139,6 +145,26 @@ std::string PathImpl::tempImpl() } +std::string PathImpl::configImpl() +{ + std::string result; + + // if PROGRAMDATA environment variable not exist, return system directory instead + try + { + result = EnvironmentImpl::getImpl("PROGRAMDATA"); + } + catch (NotFoundException&) + { + result = systemImpl(); + } + + std::string::size_type n = result.size(); + if (n > 0 && result[n - 1] != '\\') + result.append("\\"); + return result; +} + std::string PathImpl::nullImpl() { return "NUL:"; diff --git a/Foundation/src/Path_WIN32U.cpp b/Foundation/src/Path_WIN32U.cpp index 750260c22..b4db58bb3 100644 --- a/Foundation/src/Path_WIN32U.cpp +++ b/Foundation/src/Path_WIN32U.cpp @@ -132,6 +132,14 @@ std::string PathImpl::cacheHomeImpl() } +<<<<<<< HEAD +======= +std::string PathImpl::tempHomeImpl() +{ + return tempImpl(); +} + +>>>>>>> 06e59cb... add Windows compliant implementation of XDG Base Directory Specification std::string PathImpl::tempImpl() { Buffer buffer(MAX_PATH_LEN); @@ -150,6 +158,26 @@ std::string PathImpl::tempImpl() } +std::string PathImpl::configImpl() +{ + std::string result; + + // if PROGRAMDATA environment variable not exist, return system directory instead + try + { + result = EnvironmentImpl::getImpl("PROGRAMDATA"); + } + catch (NotFoundException&) + { + result = systemImpl(); + } + + std::string::size_type n = result.size(); + if (n > 0 && result[n - 1] != '\\') + result.append("\\"); + return result; +} + std::string PathImpl::nullImpl() { return "NUL:";