diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-08 20:42:28 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-10 14:18:18 +0100 |
commit | 603b63b4c154882ecfe95ae3c6960b08eb9fb626 (patch) | |
tree | 5d3aefa2c0a76d8665f302f82a18e0a0ac5cece7 /sfx2/source | |
parent | 21795eb3d3eca8e3c2eadc1e80dfc2d032a3c861 (diff) |
tdf#121288: ReplaceFile WinAPI doesn't play nicely with WebDAV mapped drives
Change-Id: I0d7a64459de283dc10448e0086c66bedbf132553
Reviewed-on: https://gerrit.libreoffice.org/63133
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
Tested-by: Gabor Kelemen <kelemeng@ubuntu.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 9e55c128bb71..61e92a3e0d5f 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -202,7 +202,7 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL) } /// Determines if rURL is safe to move or not. -bool IsFileMovable(const OUString& rURL) +bool IsFileMovable(const INetURLObject& rURL) { #ifdef MACOSX (void)rURL; @@ -210,22 +210,25 @@ bool IsFileMovable(const OUString& rURL) return false; #else - if (!comphelper::isFileUrl(rURL)) + if (rURL.GetProtocol() != INetProtocol::File) // Not a file:// URL. return false; #ifdef UNX - OUString rPath; - if (osl::FileBase::getSystemPathFromFileURL(rURL, rPath) != osl::FileBase::E_None) + OUString sPath = rURL.getFSysPath(FSysStyle::Unix); + if (sPath.isEmpty()) return false; struct stat buf; - if (lstat(rPath.toUtf8().getStr(), &buf) != 0) + if (lstat(sPath.toUtf8().getStr(), &buf) != 0) return false; // Hardlink or symlink: osl::File::move() doesn't play with these nicely. if (buf.st_nlink > 1 || S_ISLNK(buf.st_mode)) return false; +#elif defined _WIN32 + if (tools::IsMappedWebDAVPath(rURL)) + return false; #endif return true; @@ -1845,7 +1848,7 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); - if (IsFileMovable(aDestMainURL) + if (IsFileMovable(aDest) && osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) { if (nAttributes) |