[libcxx-commits] [libcxx] [libcxx][test] Create feature host-can-create-symlinks (PR #82204)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 18 20:48:03 PST 2024
================
@@ -474,6 +476,36 @@ def _getAndroidDeviceApi(cfg):
),
]
+# Creation of symlinks require elevated privileges on Windows unless
+# Windows developer mode is enabled.
+def check_unprivileged_symlinks(cfg):
+ if not platform.system().lower().startswith("windows"):
+ return True
+
+ temp_file = tempfile.NamedTemporaryFile(delete=False)
+ temp_file_path = temp_file.name
+
+ # Close the file to ensure it can be linked.
+ temp_file.close()
+
+ symlink_file_path = temp_file_path + "_symlink"
+ try:
+ os.symlink(temp_file_path, symlink_file_path)
+ return True
+ except Exception as e:
----------------
hawkinsw wrote:
Just curious: Do we want to only catch `OSError` here? If there is another exception thrown (for _whatever_ reason), we probably want that to make its way to a higher level. Only `OSError` really tells us the information that we need to know (whether the user has privileges required to make symlinks).
https://github.com/llvm/llvm-project/pull/82204
More information about the libcxx-commits
mailing list