fix File::linkTo() on Windows

This commit is contained in:
Günter Obiltschnig
2017-12-14 11:44:30 +01:00
parent 07d900b979
commit 3f8c637610
2 changed files with 21 additions and 2 deletions

View File

@@ -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
}
}