コード例 #1
0
ファイル: Preferences.cpp プロジェクト: TabitaPL/Pasjans
void Preferences::SavePreferences()
{
    StringList written;
    hashmap_ns::hash_map<String, LoadedVariableMap>::iterator it = _preferenceVariables.begin();
    while (it != _preferenceVariables.end())
    {
        written.push_back(it->first + " = {");
        LoadedVariableMap::iterator lvmIt = it->second.begin();
        while (lvmIt != it->second.end())
        {
            if (lvmIt->second._setAs == 2)
            {
                written.push_back("\t" + lvmIt->first + " = \"" + lvmIt->second._string + "\",");
            }
            else
            {
                written.push_back("\t" + lvmIt->first + " = " + lvmIt->second._string + ",");
            }
            lvmIt++;
        }
        written.push_back("}\n");
        it++;
    }
    WriteLinesToFile(GetUserPrefsPath(), written);
}
コード例 #2
0
bool RepairXmlFile(std::vector<std::wstring>& XmlContents)
{
    // Really, the only way we can repair the file is if the starting end ending comments are left intact,
    // so we'll start by trying to locate them.
    int firstLineNumber;
    if (!FindXmlFirstLine(XmlContents, XmlEntries.front(), firstLineNumber))
    {
        return false;
    }

    int lastLineNumber;
    if (!FindXmlFirstLine(XmlContents, XmlEntries.back(), lastLineNumber))
    {
        return false;
    }

    // Verify line numbers are okay, and remove.
    if (firstLineNumber >= lastLineNumber)
    {
        return false;
    }
    XmlContents.erase(XmlContents.begin() + firstLineNumber, XmlContents.begin() + lastLineNumber + 1);

    // Add lines back in.
    if (!InsertXmlEntries(XmlContents))
    {
        return false;
    }
    else
    {
        return WriteLinesToFile(XmlFileName, XmlContents);
    }
}
コード例 #3
0
bool VerifyXmlEntries()
{
    if (!DoesFileExist(XmlFileName))
    {
        return false;
    }

    std::vector<std::wstring> XmlContents;
    ReadXmlFile(XmlFileName, XmlContents);

    int lineNumber;
    if (!FindXmlFirstLine(XmlContents, XmlEntries[0], lineNumber))
    {
        // Couldn't find the first line of the xml entries in the xml file, so we need to add them.
        if (!InsertXmlEntries(XmlContents))
        {
            return false;
        }
        else
        {
            return WriteLinesToFile(XmlFileName, XmlContents);
        }
    }
    else
    {
        // we found the first line, good enough.  Don't want to FORCE people to
        // setup this file exactly like me, but just want to add the entries if
        // they haven't got them already.
        
        // we'll check and see if what's there matches the internals of what we
        // have here.  If they match, we'll exit normally, otherwise we'll prompt
        // the user, asking them if they want us to repair the builder_setup.xml.

        if (CheckXmlMatch(XmlContents))
        {
            return true;  //matches, nothing to do here.
        }
        else
        {
            std::wstring message = L"It appears that the portion of builder_setup.xml that deals with "
                                   L"blender files is out of date, or has been altered.  Would you like "
                                   L"to repair this now?";
            int result = MessageBox(NULL, message.c_str(), L"Repair builder_setup.xml?", MB_YESNO | MB_ICONEXCLAMATION);
            if (result != IDYES)
            {
                return true;  // we tried, but they don't want it.
            }

            // attempt to repair XML file.
            if (!RepairXmlFile(XmlContents))
            {
                std::wstring message = L"Unable to repair xml file.  Delete builder_setup.xml, and run verify files through steam to replace it.  Then run this utility again.";
                MessageBox(NULL, message.c_str(), L"Error", MB_OK | MB_ICONERROR);
            }
            return true;
        }
    }
}
コード例 #4
0
ファイル: Log.cpp プロジェクト: Venom483/Angel-3.1
FileLog::FileLog( const String& fileName )
: _fileName(fileName)
{
	//TODO: may want to backup the old log?
	//Clear the current log
	StringList logHeader;
	logHeader.push_back( String("Opened Log: ") + _fileName );
	logHeader.push_back( String("On: ") + __GetTimeString() );
	logHeader.push_back("");
	WriteLinesToFile( _fileName, logHeader );
}
コード例 #5
0
bool ReAquireScript(int i)
{
    return WriteLinesToFile(SCRIPTS_DIRECTORY + PYTHON_FILE_NAMES[i], PYTHON_FILE_DATAS[i]);
}