|
From: andrew7 <bd...@us...> - 2007-06-09 17:13:35
|
Update of /cvsroot/smartwin/SmartWin/include/io In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28124 Modified Files: iolib.h Log Message: Added the utility fileToVect( const SmartUtil::tstring & filePath, vector<unsigned char> & dat ) Index: iolib.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/include/io/iolib.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- iolib.h 18 Feb 2007 00:47:16 -0000 1.13 +++ iolib.h 9 Jun 2007 17:13:32 -0000 1.14 @@ -195,6 +195,27 @@ return( true ); } +//------------------------------------------------------------------------- + + +static bool fileToVect( const SmartUtil::tstring & filePath, vector<unsigned char> & dat ) +{ + dat.clear(); + if ( 0 == filePath.size() != 0 ) return( false ); + + + basic_ifstream< TCHAR > file( SmartUtil::AsciiGuaranteed::doConvert( filePath.c_str(), + SmartUtil::ConversionCodepage::UTF8 ).c_str(), + ios_base::binary ); + if ( ! file.good() ) return( false ); + + do { + dat.push_back( file.get() ); + } while ( file.good() ); + + return( true ); +} + //------------------------------------------------------------------------- |