void test_this_pointer2() { Buf myBuf("my buffer", 10); Buf yourBuf("your buffer", 12); // Display 'my buffer' myBuf.Display(); // assignment opperator myBuf = yourBuf; // Display 'your buffer' myBuf.Display(); }
int mockArchiveCopyPlugin( int mode, const char* srcFileName, const char* destFileName ) { int trans_buff_size = 0; irods::error ret = irods::get_advanced_setting<int>( irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS, trans_buff_size ); if ( !ret.ok() ) { return ret.code(); } trans_buff_size *= 1024 * 1024; int inFd, outFd; std::vector<char> myBuf( trans_buff_size ); rodsLong_t bytesCopied = 0; int bytesRead; int bytesWritten; int status; struct stat statbuf; inFd = open( srcFileName, O_RDONLY, 0 ); status = stat( srcFileName, &statbuf ); if ( inFd < 0 ) { status = UNIX_FILE_OPEN_ERR - errno; rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: open error for srcFileName %s, status = %d", srcFileName, status ); return status; } else if ( status < 0 ) { status = UNIX_FILE_STAT_ERR - errno; rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: stat of %s error, status = %d", srcFileName, status ); close( inFd ); // JMC cppcheck - resource return status; } else if ( ( statbuf.st_mode & S_IFREG ) == 0 ) { rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: open error for srcFileName %s, status = %d", srcFileName, UNIX_FILE_OPEN_ERR ); close( inFd ); // JMC cppcheck - resource return status; } outFd = open( destFileName, O_WRONLY | O_CREAT | O_TRUNC, mode ); if ( outFd < 0 ) { status = UNIX_FILE_OPEN_ERR - errno; rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: open error for destFileName %s, status = %d", destFileName, status ); close( inFd ); return status; } while ( ( bytesRead = read( inFd, ( void * ) myBuf.data(), trans_buff_size ) ) > 0 ) { bytesWritten = write( outFd, ( void * ) myBuf.data(), bytesRead ); if ( bytesWritten <= 0 ) { status = UNIX_FILE_WRITE_ERR - errno; rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: write error for srcFileName %s, status = %d", destFileName, status ); close( inFd ); close( outFd ); return status; } bytesCopied += bytesWritten; } close( inFd ); close( outFd ); if ( bytesCopied != statbuf.st_size ) { rodsLog( LOG_ERROR, "mockArchiveCopyPlugin: Copied size %lld does not match source \ size %lld of %s", bytesCopied, statbuf.st_size, srcFileName ); return SYS_COPY_LEN_ERR; } else { return 0; } } // mockArchiveCopyPlugin