int CopyFile( char* strSrc, char* strDes, int bForce ) { if( !bForce ) { if( CompareSize(strSrc, strDes)==0 )return 0; } FILE* pfSrc = fopen( strSrc, "rb" ); if( pfSrc==NULL )return -1; FILE* pfDes = fopen( strDes, "wb" ); if( pfDes==NULL ) { fclose(pfSrc); return -1; } char buf[BUFSIZE]; while( !feof(pfSrc) ) { int nRead = fread( buf, sizeof(char), BUFSIZE, pfSrc ); if( nRead>0 ) { fwrite( buf, sizeof(char), nRead, pfDes ); } } fclose( pfSrc ); fclose( pfDes ); struct stat statsrc; stat( strSrc, &statsrc ); chmod( strDes, statsrc.st_mode ); return 0; }
bool DumpWrapper<T>::Compare(DumpBuffer& buffer, float threshold, OutputFormat output, size_t length , size_t stride ,size_t start) { if(!CompareName(buffer)) return false; if(!CompareSize(buffer)){ cout << "Buffer " << getName() << " differ in number of elements: " << getSize()/sizeof(T) << " / " << buffer.getSize()/sizeof(T) << endl; return false; } return CompareData((void*)buffer.getData(), threshold, output, length ,stride ,start); }
bool DumpBuffer::Compare(DumpBuffer& buffer, float threshold, OutputFormat output, size_t length , size_t stride ,size_t start) { if(!CompareName(buffer)) return false; if(!CompareSize(buffer)){ cout << "Buffer " << getName() << " differ in size: " << getSize() << " / " << buffer.getSize() << " Bytes" << endl; return false; } return CompareData((void*)buffer.getData(), threshold, output, length ,stride ,start); }