Bool TgaFile::SaveToFile( const std::string & p_Filename, const Bool p_Validate ) { // Load a string stream. std::stringstream ss; // Save the stream. if( SaveToStream( ss, p_Validate ) == false ) { return false; } // Open the file. std::ofstream fout( p_Filename.c_str( ), std::fstream::binary ); if( fout.is_open( ) == false ) { bitLogGraErr( "Can not open the file." ); return false; } // Write the string stream to the file fout.write( ss.str( ).c_str( ), ss.str( ).length( ) ); // Close the file. fout.close( ); // Succeeded. return true; }
bool IStateStore::SaveToFile( const wxString& fileName ) { STOPWATCH_BEGIN; wxFileOutputStream stream( mMyTemporary ); bool res = false; if (stream.IsOk()) { wxBusyInfo info("Saving, please wait..."); res = SaveToStream( stream ); stream.Close(); if (res) { res = this->RenameTemporary( fileName ); } } else { wxLogError(wxString::Format("%s::SaveToFile: can't create temporary file (%s) to save data!", mMyName, mMyTemporary)); } STOPWATCH_END(wxString("IStateStore::SaveToFile ").Append(fileName)); return res; }
bool XMLNode::SaveToFile(const std::string& file_name) const { InterruptGuard guard; std::ofstream out(file_name.c_str(), std::ios::out); if (!out) return false; bool r = SaveToStream(out); out.close(); return r; }
bool CDocument::SaveToFile(const std::wstring& wsPath) { CFileStream* pStream = new CFileStream(); if (!pStream || !pStream->OpenFile(wsPath, true)) return false; if (m_pJbig2) m_pJbig2->FlushStreams(); SaveToStream((CStream*)pStream); delete pStream; return true; }
Bool TgaFile::SaveToMemory( std::string & p_Memory, const Bool p_Validate ) { // Load a string stream std::stringstream ss; // Save the stream if( SaveToStream( ss, p_Validate ) == false ) { return false; } // Get the string p_Memory = ss.str( ); // Succeeded return true; }