79722143

Date: 2025-08-01 06:39:14
Score: 0.5
Natty:
Report link

I think I found the answer. But I want to know if there is a better way to do it.

def convert_to_unc_path(path: str) -> str:
    # Check if already escaped UNC path (starts with \\\\?\\)
    if path.startswith("\\\\\\\\?\\\\"):
        return path
    
    # Check if raw UNC path (starts with \\?\)  
    elif path.startswith("\\\\?\\"):
        return path.replace("\\", "\\\\")
    
    # Regular path, add UNC prefix and escape
    else:
        unc_path = "\\\\?\\" + path
        return unc_path.replace("\\", "\\\\")

Reasons:
  • Blacklisted phrase (1): I want to know
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: tandem