From: <cn...@us...> - 2009-10-27 03:10:06
|
Revision: 587 http://hgengine.svn.sourceforge.net/hgengine/?rev=587&view=rev Author: cnlohr Date: 2009-10-27 03:09:56 +0000 (Tue, 27 Oct 2009) Log Message: ----------- add utility function for file writing Modified Paths: -------------- Mercury2/src/MercuryUtil.cpp Mercury2/src/MercuryUtil.h Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2009-10-27 03:09:34 UTC (rev 586) +++ Mercury2/src/MercuryUtil.cpp 2009-10-27 03:09:56 UTC (rev 587) @@ -228,6 +228,15 @@ return length; } +bool StringToFile( const MString & sFileName, const MString & data ) +{ + MercuryFile * f = FILEMAN.Open( sFileName, MFP_WRITE_ONLY ); + if( !f ) return false; + f->Write( data.c_str(), data.length() ); + delete f; +} + + int GeneralUsePrimes[] = { 3, 13, 37, 73, 131, 229, 337, 821, 2477, 4594, 8941, 14797, 24953, 39041, 60811, 104729 }; int GetAPrime( int ith ) Modified: Mercury2/src/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-10-27 03:09:34 UTC (rev 586) +++ Mercury2/src/MercuryUtil.h 2009-10-27 03:09:56 UTC (rev 587) @@ -96,6 +96,9 @@ ///Open up filename: sFileName and dump it into a new buffer; you must delete the return value when done. ///The return value is -1 if there was an issue, otherwise it is valid. long FileToString( const MString & sFileName, char * & data ); + +///Take a string and write it to the hard drive as a file. True indicates everything is okay. +bool StringToFile( const MString & sFileName, const MString & data ); /* These two functions are very different */ /// nextPow2 will go to the NEXT power of 2 even if x is already a power of 2. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |