| 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 | |
| 147 | static 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; |
no test coverage detected