int cpFileUtil( rcComm_t *conn, char *srcPath, char *targPath, rodsLong_t srcSize, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp ) { int status; struct timeval startTime, endTime; if ( srcPath == NULL || targPath == NULL ) { rodsLog( LOG_ERROR, "cpFileUtil: NULL srcPath or targPath in cp" ); return USER__NULL_INPUT_ERR; } if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &startTime, ( struct timezone * )0 ); } if ( gGuiProgressCB != NULL ) { rstrcpy( conn->operProgress.curFileName, srcPath, MAX_NAME_LEN ); conn->operProgress.curFileSize = srcSize; conn->operProgress.curFileSizeDone = 0; conn->operProgress.flag = 0; gGuiProgressCB( &conn->operProgress ); } rstrcpy( dataObjCopyInp->destDataObjInp.objPath, targPath, MAX_NAME_LEN ); rstrcpy( dataObjCopyInp->srcDataObjInp.objPath, srcPath, MAX_NAME_LEN ); dataObjCopyInp->srcDataObjInp.dataSize = -1; status = rcDataObjCopy( conn, dataObjCopyInp ); if ( status >= 0 ) { if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &endTime, ( struct timezone * )0 ); printTiming( conn, dataObjCopyInp->destDataObjInp.objPath, conn->transStat.bytesWritten, NULL, &startTime, &endTime ); } if ( gGuiProgressCB != NULL ) { conn->operProgress.totalNumFilesDone++; conn->operProgress.totalFileSizeDone += srcSize; } } return status; }
int sendBulkPut( rcComm_t *conn, bulkOprInp_t *bulkOprInp, bulkOprInfo_t *bulkOprInfo, rodsArguments_t *rodsArgs ) { struct timeval startTime, endTime; int status = 0; if ( bulkOprInfo == NULL || bulkOprInfo->count <= 0 ) { return 0; } if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &startTime, ( struct timezone * )0 ); } /* send it */ if ( bulkOprInfo->bytesBuf.buf != NULL ) { status = rcBulkDataObjPut( conn, bulkOprInp, &bulkOprInfo->bytesBuf ); } /* reset the row count */ bulkOprInp->attriArray.rowCnt = 0; if ( bulkOprInfo->forceFlagAdded == 1 ) { rmKeyVal( &bulkOprInp->condInput, FORCE_FLAG_KW ); bulkOprInfo->forceFlagAdded = 0; } if ( status >= 0 ) { if ( rodsArgs->verbose == True ) { printf( "Bulk upload %d files.\n", bulkOprInfo->count ); ( void ) gettimeofday( &endTime, ( struct timezone * )0 ); printTiming( conn, bulkOprInfo->cachedTargPath, bulkOprInfo->size, bulkOprInfo->cachedTargPath, &startTime, &endTime ); } if ( gGuiProgressCB != NULL ) { rstrcpy( conn->operProgress.curFileName, bulkOprInfo->cachedTargPath, MAX_NAME_LEN ); conn->operProgress.totalNumFilesDone += bulkOprInfo->count; conn->operProgress.totalFileSizeDone += bulkOprInfo->size; gGuiProgressCB( &conn->operProgress ); } } return status; }
int getDataObjUtil (rcComm_t *conn, char *srcPath, char *targPath, rodsLong_t srcSize, uint dataMode, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp) { int status; struct timeval startTime, endTime; if (srcPath == NULL || targPath == NULL) { rodsLog (LOG_ERROR, "getDataObjUtil: NULL srcPath or targPath input"); return (USER__NULL_INPUT_ERR); } if (conn->fileRestart.info.status == FILE_RESTARTED && strcmp (conn->fileRestart.info.objPath, srcPath) == 0) { /* it was restarted */ conn->fileRestart.info.status = FILE_NOT_RESTART; return 0; } if (rodsArgs->verbose == True) { (void) gettimeofday(&startTime, (struct timezone *)0); } if (gGuiProgressCB != NULL) { rstrcpy (conn->operProgress.curFileName, srcPath, MAX_NAME_LEN); conn->operProgress.curFileSize = srcSize; conn->operProgress.curFileSizeDone = 0; conn->operProgress.flag = 0; gGuiProgressCB (&conn->operProgress); } rstrcpy (dataObjOprInp->objPath, srcPath, MAX_NAME_LEN); /* rcDataObjGet verifies dataSize if given */ if (rodsArgs->replNum == True || rodsArgs->resource == True) { /* don't verify because it may be an old copy and hence the size * could be wrong */ dataObjOprInp->dataSize = 0; } else { dataObjOprInp->dataSize = srcSize; } status = rcDataObjGet (conn, dataObjOprInp, targPath); if (status >= 0) { /* old objState use numCopies in place of dataMode. * Just a sanity check */ myChmod (targPath, dataMode); if (rodsArgs->verbose == True) { (void) gettimeofday(&endTime, (struct timezone *)0); printTiming (conn, dataObjOprInp->objPath, srcSize, targPath, &startTime, &endTime); } if (gGuiProgressCB != NULL) { conn->operProgress.totalNumFilesDone++; conn->operProgress.totalFileSizeDone += srcSize; } } return (status); }
int putFileUtil( rcComm_t *conn, char *srcPath, char *targPath, rodsLong_t srcSize, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp ) { int status; struct timeval startTime, endTime; if ( srcPath == NULL || targPath == NULL ) { rodsLog( LOG_ERROR, "putFileUtil: NULL srcPath or targPath input" ); return USER__NULL_INPUT_ERR; } if ( conn->fileRestart.info.status == FILE_RESTARTED && strcmp( conn->fileRestart.info.objPath, targPath ) == 0 ) { /* it was restarted */ conn->fileRestart.info.status = FILE_NOT_RESTART; return 0; } if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &startTime, ( struct timezone * )0 ); } if ( gGuiProgressCB != NULL ) { rstrcpy( conn->operProgress.curFileName, srcPath, MAX_NAME_LEN ); conn->operProgress.curFileSize = srcSize; conn->operProgress.curFileSizeDone = 0; conn->operProgress.flag = 0; gGuiProgressCB( &conn->operProgress ); } /* have to take care of checksum here since it needs to be recalculated */ if ( rodsArgs->checksum == True ) { // set the expected flag to indicate that we want a server-side // checksum computed and stored in the catalog addKeyVal( &dataObjOprInp->condInput, REG_CHKSUM_KW, "" ); } else if ( rodsArgs->verifyChecksum == True ) { rodsEnv env; int ret = getRodsEnv( &env ); if ( ret < 0 ) { rodsLog( LOG_ERROR, "putFileUtil - failed to capture rods env %d", ret ); return ret; } status = rcChksumLocFile( srcPath, VERIFY_CHKSUM_KW, &dataObjOprInp->condInput, env.rodsDefaultHashScheme ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "putFileUtil: rcChksumLocFile error for %s, status = %d", srcPath, status ); return status; } } if ( strlen( targPath ) >= MAX_PATH_ALLOWED - 1 ) { return USER_PATH_EXCEEDS_MAX; } rstrcpy( dataObjOprInp->objPath, targPath, MAX_NAME_LEN ); dataObjOprInp->dataSize = srcSize; status = rcDataObjPut( conn, dataObjOprInp, srcPath ); if ( status >= 0 ) { if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &endTime, ( struct timezone * )0 ); printTiming( conn, dataObjOprInp->objPath, srcSize, srcPath, &startTime, &endTime ); } if ( gGuiProgressCB != NULL ) { conn->operProgress.totalNumFilesDone++; conn->operProgress.totalFileSizeDone += srcSize; } } return status; }