KWSys 2026-04-17 (b288192e)

Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit b288192ebef6480991ebcc85a256cf098ed29d49 (master).

Upstream Shortlog
-----------------

Brad King (1):
      151d01f1 SystemTools: Drop unused CreateSymlink function
This commit is contained in:
KWSys Upstream
2026-04-17 10:40:59 -04:00
committed by Brad King
parent 27b8881331
commit f43502f85d
3 changed files with 0 additions and 68 deletions
-38
View File
@@ -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)
{
-7
View File
@@ -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.
-23
View File
@@ -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;