MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / WindowsPath_createDirectoryAlias

Function WindowsPath_createDirectoryAlias

Tools/ToolsBootstrap.c:143–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 return written > 0 && (size_t)written < transportCapacity;
142 }
143 int written = _snwprintf(transportPath, transportCapacity, L"\\\\?\\%ls", logicalPath);
144 return written > 0 && (size_t)written < transportCapacity;
145}
146
147static int WindowsPath_createDirectoryAlias(const char* aliasPathUtf8, const char* targetPathUtf8) {
148 wchar_t aliasPath[SC_WINDOWS_TRANSPORT_PATH_CAPACITY + 1];
149 wchar_t targetPath[SC_WINDOWS_TRANSPORT_PATH_CAPACITY + 1];
150 if (!WindowsPath_prepareTransportPath(aliasPathUtf8, aliasPath, SC_WINDOWS_TRANSPORT_PATH_CAPACITY + 1) ||
151 !WindowsPath_prepareTransportPath(targetPathUtf8, targetPath, SC_WINDOWS_TRANSPORT_PATH_CAPACITY + 1)) {
152 return 0;
153 }
154
155 DWORD attributes = GetFileAttributesW(aliasPath);
156 if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
157 return 1;
158 }
159
160 DWORD flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
161#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
162 flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
163#endif
164 return CreateSymbolicLinkW(aliasPath, targetPath, flags) != 0;

Callers 1

setupCompilationFunction · 0.85

Calls 1

Tested by

no test coverage detected