コード例 #1
0
ファイル: Project.cpp プロジェクト: cherrysiminlin/ofSketch
void Project::save(const Json::Value& data)
{
    // This method saves differences only
    // TODO: this is not working for some reason...
    if (_data != data)
    {
        ofLogVerbose("Project::save") << data.toStyledString();

        if (_data["projectFile"] != data["projectFile"])
        {
            _data["projectFile"] = data["projectFile"];
            _saveFile(_data["projectFile"]);
        }

        // uses nested for loop in case classes are not in the same order
        std::vector<Json::Value> newClasses;
        std::vector<Json::Value> deletedClasses;

        for (unsigned int i = 0; i < _data["classes"].size(); ++i)
        {
            Json::Value& classFile = _data["classes"][i];

            bool matchFound = false;

            for (unsigned int j = 0; j < data.size(); ++j)
            {
                const Json::Value& newClassFile = data["classes"][j];

                if (classFile["fileName"] == newClassFile["fileName"]) 
                {
                    if (classFile != newClassFile)
                    {
                        classFile = newClassFile;
                        _saveFile(classFile);
                    }

                    matchFound = true;
                    break;
                }
            }

            if (!matchFound) _saveFile(classFile); // class is new
        }
    }
    else
    {
        ofLogNotice("Project::save") << "Project data is the same. Not saving project.";
    }
}
コード例 #2
0
ファイル: MainFrame.cpp プロジェクト: Aishiro/ATools
void CMainFrame::SaveFileAs()
{
	const string filename = QFileDialog::getSaveFileName(this, tr("Enregistrer le SFX"), "SFX/", tr("Fichier SFX") % " (*.sfx)");

	if (!filename.isEmpty())
	{
		setWindowTitle("SfxEditor - " % QFileInfo(filename).fileName());
		m_filename = filename;
		_saveFile(m_filename);
	}
}
コード例 #3
0
void CRRMsgHandler4FileUpload::accept( const CRRMsgMetaData& rmsgMetaData, const CRRMsgFT* pRMsgFT ) {
	CRFUParam fuParam;
	const Json::Value& valParams = pRMsgFT->m_jsonRoot[ "params" ];

	if ( !_parseFUParam( valParams, fuParam ) )
	    return;
	
	if ( !_saveFile( &fuParam, pRMsgFT ) )
		return;

	// send success ack.
	_sendSuccessAck( pRMsgFT->m_nCmdSN, rmsgMetaData, fuParam );
}
コード例 #4
0
ファイル: MainFrame.cpp プロジェクト: Aishiro/ATools
void CMainFrame::SaveFile()
{
	if (m_filename.isEmpty())
	{
		m_filename = QFileDialog::getSaveFileName(this, tr("Enregistrer le SFX"), "SFX/", tr("Fichier SFX") % " (*.sfx)");

		if (!m_filename.isEmpty())
			setWindowTitle("SfxEditor - " % QFileInfo(m_filename).fileName());
	}

	if (!m_filename.isEmpty())
		_saveFile(m_filename);
}
コード例 #5
0
ファイル: Project.cpp プロジェクト: cherrysiminlin/ofSketch
Json::Value Project::createClass(const std::string& className)
{
    std::string fileContents = _classFileTemplate;
    ofStringReplace(fileContents, "<classname>", className);

    ofLogVerbose("Project::createClass") << "fileContents: "<< fileContents;

    Json::Value classFile;
    // TODO: Load extension from settings
    classFile["fileName"] = className + "." + SKETCH_FILE_EXTENSION;
    classFile["name"] = className;
    classFile["fileContents"] = fileContents;
    _data["classes"][getNumClasses()] = classFile;
    // TODO: re-loading is a terribly slow way to delete. Come back and optimize.
    // Simply need to remove the Json::Value class in _data["classes"]
    _saveFile(classFile);
    return classFile;
}
コード例 #6
0
ファイル: CommonLib.cpp プロジェクト: backjy/kongkongxiyou
bool CommonLib::saveFile(const char *filePath, const char *fileData,const size_t fileSize)
{
    return _saveFile(filePath,fileData,strlen(fileData));
}