////////////////////////////////////////////////////////////////////////// // saveDependancy void CsCore::saveDependancies( const BcPath& FileName ) { BcPath DependanciesFileName( FileName ); // Append new extension. DependanciesFileName.append( ".dep" ); // Json::Value Object( Json::arrayValue ); if( DependancyMap_.find( *FileName ) != DependancyMap_.end() ) { CsDependancyList& DependancyList = DependancyMap_[ *FileName ]; for( CsDependancyListIterator It( DependancyList.begin() ); It != DependancyList.end(); ++It ) { Object.append( saveDependancy( (*It) ) ); } } // Output using styled writer. Json::StyledWriter Writer; std::string JsonOutput = Writer.write( Object ); BcFile OutFile; if( OutFile.open( (*DependanciesFileName).c_str(), bcFM_WRITE ) ) { OutFile.write( JsonOutput.c_str(), JsonOutput.size() ); OutFile.close(); } }
////////////////////////////////////////////////////////////////////////// // loadDependancies void CsCore::loadDependancies( const BcPath& FileName ) { BcPath DependanciesFileName( FileName ); // Append new extension. DependanciesFileName.append( ".dep" ); // Overwrite old dependancy list. DependancyMap_[ *FileName ] = CsDependancyList(); // Open dependancy file. BcFile OutFile; if( OutFile.open( (*DependanciesFileName).c_str(), bcFM_READ ) ) { BcU32 BufferSize = OutFile.size() + 1; BcChar* pJsonData = new BcChar[ BufferSize ]; BcMemZero( pJsonData, BufferSize ); OutFile.read( pJsonData, OutFile.size() ); Json::Value Root; Json::Reader JsonReader; if( JsonReader.parse( pJsonData, pJsonData + OutFile.size(), Root ) ) { // Create a new dependancy list. CsDependancyList DependancyList; // Iterate over all dependancies for file and parse. for( Json::Value::iterator It( Root.begin() ); It != Root.end(); ++It ) { const Json::Value& Value = (*It); CsDependancy Dependancy = loadDependancy( Value ); DependancyList.push_back( Dependancy ); } // Assign. DependancyMap_[ *FileName ] = DependancyList; } OutFile.close(); } }