コード例 #1
0
ファイル: Helpers.cpp プロジェクト: ianwjhalliday/ChakraCore
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);
}
コード例 #2
0
void Helpers::GetTTDDirectory(const wchar* curi, size_t* uriLength, char* uri, size_t bufferLength)
{
    TTDHostBuildCurrentExeDirectory(uri, uriLength, bufferLength);

    Helpers::CreateTTDDirectoryAsNeeded(uriLength, uri, "_ttdlog", curi);
}