diff --git a/Foundation/src/File_WIN32.cpp b/Foundation/src/File_WIN32.cpp index 355fd16ce..b7362a813 100644 --- a/Foundation/src/File_WIN32.cpp +++ b/Foundation/src/File_WIN32.cpp @@ -317,8 +317,18 @@ void FileImpl::linkToImpl(const std::string& path, int type) const } else { - if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), (isDirectoryImpl() ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) == 0) +#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY) + DWORD flags = 0; + if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY; +#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE + flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; +#endif + if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), flags) == 0) handleLastErrorImpl(_path); +#else + throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK") +#endif + } } diff --git a/Foundation/src/File_WIN32U.cpp b/Foundation/src/File_WIN32U.cpp index 39b2ec2a3..28ff085d8 100644 --- a/Foundation/src/File_WIN32U.cpp +++ b/Foundation/src/File_WIN32U.cpp @@ -327,8 +327,17 @@ void FileImpl::linkToImpl(const std::string& path, int type) const } else { - if (CreateSymbolicLinkW(upath.c_str(), _upath.c_str(), (isDirectoryImpl() ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) == 0) +#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY) + DWORD flags = 0; + if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY; +#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE + flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; +#endif + if (CreateSymbolicLinkW(upath.c_str(), _upath.c_str(), flags) == 0) handleLastErrorImpl(_path); +#else + throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK"); +#endif } }