MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / TryUriDecodeLen

Function TryUriDecodeLen

extern/nfd/nfd_portal.cpp:963–982  ·  view source on GitHub ↗

Returns true if the given file URI is decodable (i.e. not malformed), and false otherwise. If this function returns true, then `out` will be populated with the length of the decoded URI and `fileUriEnd` will point to the trailing null byte of `fileUri`. Otherwise, `out` and `fileUriEnd` will be unmodified.

Source from the content-addressed store, hash-verified

961// and `fileUriEnd` will point to the trailing null byte of `fileUri`. Otherwise, `out` and
962// `fileUriEnd` will be unmodified.
963bool TryUriDecodeLen(const char* fileUri, size_t& out, const char*& fileUriEnd) {
964 size_t len = 0;
965 while (*fileUri) {
966 if (*fileUri != '%') {
967 ++fileUri;
968 } else {
969 if (*(fileUri + 1) == '\0' || *(fileUri + 2) == '\0') {
970 return false;
971 }
972 if (!IsHex(*(fileUri + 1)) || !IsHex(*(fileUri + 2))) {
973 return false;
974 }
975 fileUri += 3;
976 }
977 ++len;
978 }
979 out = len;
980 fileUriEnd = fileUri;
981 return true;
982}
983
984// Decodes the given URI and writes it to `outPath`. The caller must ensure that the given URI is
985// not malformed (typically with a prior call to `TryUriDecodeLen`). This function does not write

Callers 2

AllocAndCopyFilePathFunction · 0.85

Calls 1

IsHexFunction · 0.85

Tested by

no test coverage detected