mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
added Poco::File::linkTo()
This commit is contained in:
@@ -163,10 +163,16 @@ bool FileImpl::isDirectoryImpl() const
|
||||
|
||||
bool FileImpl::isLinkImpl() const
|
||||
{
|
||||
return false;
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
DWORD attr = GetFileAttributes(_upath.c_str());
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0 && (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FileImpl::isDeviceImpl() const
|
||||
{
|
||||
return
|
||||
@@ -300,6 +306,23 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::linkToImpl(const std::string& path, int type) const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
if (CreateHardLinkA(path.c_str(), _path.c_str(), NULL) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), (isDirectoryImpl() ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::removeImpl()
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
Reference in New Issue
Block a user