diff --git a/SystemTools.cxx b/SystemTools.cxx index 073bb643d7..b7e0960034 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3166,44 +3166,6 @@ bool SystemTools::FileIsFIFO(std::string const& name) #endif } -Status SystemTools::CreateSymlink(std::string const& origName, - std::string const& newName) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - DWORD flags; - if (FileIsDirectory(origName)) { - flags = SYMBOLIC_LINK_FLAG_DIRECTORY; - } else { - flags = 0; - } - - std::wstring origPath = Encoding::ToWindowsExtendedPath(origName); - std::wstring newPath = Encoding::ToWindowsExtendedPath(newName); - - Status status; - if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(), - flags | - SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)) { - status = Status::Windows_GetLastError(); - } - // Older Windows versions do not understand - // SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE - if (status.GetWindows() == ERROR_INVALID_PARAMETER) { - status = Status::Success(); - if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(), flags)) { - status = Status::Windows_GetLastError(); - } - } - - return status; -#else - if (symlink(origName.c_str(), newName.c_str()) < 0) { - return Status::POSIX_errno(); - } - return Status::Success(); -#endif -} - Status SystemTools::ReadSymlink(std::string const& newName, std::string& origName) { diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 796924e0e2..12b37406a2 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -785,13 +785,6 @@ public: unsigned long length = 256, double percent_bin = 0.05); - /** - * Create a symbolic link if the platform supports it. Returns whether - * creation succeeded. - */ - static Status CreateSymlink(std::string const& origName, - std::string const& newName); - /** * Read the contents of a symbolic link. Returns whether reading * succeeded. diff --git a/testSystemTools.cxx b/testSystemTools.cxx index b94b8f6f1b..e48525de43 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -445,29 +445,6 @@ static bool CheckFileOperations() res = false; } - std::string const testBadSymlink(testNewDir + "/badSymlink.txt"); - std::string const testBadSymlinkTgt(testNewDir + "/missing/symlinkTgt.txt"); - kwsys::Status const symlinkStatus = - kwsys::SystemTools::CreateSymlink(testBadSymlinkTgt, testBadSymlink); -#if defined(_WIN32) - // Under Windows, the user may not have enough privileges to create symlinks - if (symlinkStatus.GetWindows() != ERROR_PRIVILEGE_NOT_HELD) -#endif - { - if (!symlinkStatus.IsSuccess()) { - std::cerr << "CreateSymlink for: " << testBadSymlink << " -> " - << testBadSymlinkTgt - << " failed: " << symlinkStatus.GetString() << std::endl; - res = false; - } - - if (!kwsys::SystemTools::Touch(testBadSymlink, false)) { - std::cerr << "Problem with Touch (no create) for: " << testBadSymlink - << std::endl; - res = false; - } - } - if (!kwsys::SystemTools::Touch(testNewDir, false)) { std::cerr << "Problem with Touch (no create) for: " << testNewDir << std::endl;