void Helpers::GetTTDDirectory(const wchar* curi, size_t* uriByteLength, byte* uriBytes) { TTDHostCharType turi[MAX_PATH]; TTDHostInitEmpty(turi); if(curi[0] != _u('~')) { TTDHostCharType* status = TTDHostCWD(turi); Helpers::TTReportLastIOErrorAsNeeded(status != nullptr, "Failed to chmod directory"); TTDHostAppend(turi, TTDHostPathSeparator); TTDHostAppendWChar(turi, curi); } else { TTDHostBuildCurrentExeDirectory(turi, MAX_PATH); TTDHostAppendAscii(turi, "_ttdlog"); TTDHostAppend(turi, TTDHostPathSeparator); TTDHostAppendWChar(turi, curi + 1); } //add a path separator if one is not already present if(curi[wcslen(curi) - 1] != (wchar)TTDHostPathSeparatorChar) { TTDHostAppend(turi, TTDHostPathSeparator); } size_t turiLength = TTDHostStringLength(turi); size_t byteLengthWNull = (turiLength + 1) * sizeof(TTDHostCharType); memcpy_s(uriBytes, byteLengthWNull, turi, byteLengthWNull); *uriByteLength = turiLength * sizeof(TTDHostCharType); }
void Helpers::GetTTDDirectory(const wchar* curi, size_t* uriLength, char* uri, size_t bufferLength) { TTDHostBuildCurrentExeDirectory(uri, uriLength, bufferLength); Helpers::CreateTTDDirectoryAsNeeded(uriLength, uri, "_ttdlog", curi); }