Esempio n. 1
0
Long CModelScript::SaveTranslationToFile()
{
    SizeT  Length;
    PTChar pszTransPath;
    WChar  szBuffer[0x1000];
    CFileDisk file;
    SScriptText *pText;

    if (m_VecTextTranslation.size() == 0)
        return SCR_ERROR_EMPTY_TRANSLATION_TEXT;

    pszTransPath = (PTChar)szBuffer;
    memcpy(pszTransPath, m_ScriptPath.GetBuffer(), (m_ScriptPath.GetLength() + 1) * sizeof(*pszTransPath));
    GenerateTranslationFileName(pszTransPath);

    if (!file.Open(pszTransPath, file.FILE_ACCESS_WRITE, file.FILE_SHAREMODE_READ, file.FILE_CREATE_ALWAYS))
        return SCR_ERROR_IO_FAILED_OPEN;

    Length = BOM_UTF16_LE;
    if (!file.Write(&Length, 2))
        return SCR_ERROR_IO_FAILED_WRITE;

    Length = m_VecCharNameOriginal.size();
    if (Length != 0)
    {
        SizeT i;
        StringW *pCharName;

        i = Length;
        Length = wsprintfW(szBuffer, L"@Name=");
        pCharName = &m_VecCharNameOriginal[0];
        do
        {
            Length += wsprintfW(szBuffer + Length, L"%s,", pCharName->GetBuffer());
            ++pCharName;
        } while (--i);

        if (Length != 0)
        {
            *(PUInt32)&szBuffer[Length - 1] = 0x000A000D;
            if (!file.Write(szBuffer, ++Length * sizeof(*szBuffer)))
                return SCR_ERROR_IO_FAILED_WRITE;
        }
    }

    pText = &m_VecTextTranslation[0];
    for (SizeT i = m_VecTextTranslation.size(); i; --i)
    {
        Length = wsprintfW(
                     szBuffer,
                     L"@Text=%d,%d,%d,%s\r\n",
                     pText->PhysicalLine,
                     pText->LogicalLine,
                     pText->CharNameIndex,
                     pText->Text);
        if (!file.Write(szBuffer, Length * sizeof(*szBuffer)))
            return SCR_ERROR_IO_FAILED_WRITE;

        ++pText;
    }

    return SCR_ERROR_SUCCESS;
}
Esempio n. 2
0
		Void Hash::ComputeHash(const StringW& string)
		{
			ComputeHash((PCByte)string.GetBuffer(), string.GetSize() * sizeof(WChar));
		}
	Void SymmetricCipher::Compute(const StringW& string)
	{
		Compute((PCByte)string.GetBuffer(), string.GetSize() * sizeof(WChar));
	}