irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

mvUtil.cpp
Go to the documentation of this file.
1 
3 #ifndef windows_platform
4 #include <sys/time.h>
5 #endif
6 #include "rodsPath.h"
7 #include "rodsErrorTable.h"
8 #include "rodsLog.h"
9 #include "miscUtil.h"
10 #include "mvUtil.h"
11 #include "rcGlobalExtern.h"
12 
13 int
14 mvUtil( rcComm_t *conn, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) {
15  if ( rodsPathInp == NULL ) {
16  return USER__NULL_INPUT_ERR;
17  }
18 
19  dataObjCopyInp_t dataObjRenameInp;
20  initCondForMv( &dataObjRenameInp );
21 
22  int savedStatus = resolveRodsTarget( conn, rodsPathInp, MOVE_OPR );
23  if ( savedStatus < 0 ) {
24  rodsLogError( LOG_ERROR, savedStatus,
25  "mvUtil: resolveRodsTarget error, status = %d", savedStatus );
26  return savedStatus;
27  }
28 
29  for ( int i = 0; i < rodsPathInp->numSrc; i++ ) {
30  rodsPath_t * targPath = &rodsPathInp->targPath[i];
31 
32  int status = mvObjUtil( conn, rodsPathInp->srcPath[i].outPath,
33  targPath->outPath, targPath->objType, myRodsArgs,
34  &dataObjRenameInp );
35 
36  /* XXXX may need to return a global status */
37  if ( status < 0 &&
40  "mvUtil: mv error for %s, status = %d",
41  targPath->outPath, status );
42  savedStatus = status;
43  }
44  }
45  return savedStatus;
46 }
47 
48 int
49 mvObjUtil( rcComm_t *conn, char *srcPath, char *targPath, objType_t objType,
50  rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjRenameInp ) {
51  int status;
52  struct timeval startTime, endTime;
53 
54  if ( srcPath == NULL || targPath == NULL ) {
56  "mvFileUtil: NULL srcPath or targPath input" );
57  return USER__NULL_INPUT_ERR;
58  }
59 
60  if ( objType == DATA_OBJ_T ) {
61  dataObjRenameInp->srcDataObjInp.oprType =
62  dataObjRenameInp->destDataObjInp.oprType = RENAME_DATA_OBJ;
63  }
64  else if ( objType == COLL_OBJ_T ) {
65  dataObjRenameInp->srcDataObjInp.oprType =
66  dataObjRenameInp->destDataObjInp.oprType = RENAME_COLL;
67  }
68  else {
69  /* should not be here */
71  "mvObjUtil: invalid cp dest objType %d for %s",
72  objType, targPath );
73  return USER_INPUT_PATH_ERR;
74  }
75 
76 
77  if ( rodsArgs->verbose == True ) {
78  ( void ) gettimeofday( &startTime, ( struct timezone * )0 );
79  }
80 
81  rstrcpy( dataObjRenameInp->destDataObjInp.objPath, targPath, MAX_NAME_LEN );
82  rstrcpy( dataObjRenameInp->srcDataObjInp.objPath, srcPath, MAX_NAME_LEN );
83 
84  status = rcDataObjRename( conn, dataObjRenameInp );
85 
86  if ( status >= 0 && rodsArgs->verbose == True ) {
87  ( void ) gettimeofday( &endTime, ( struct timezone * )0 );
88  printTiming( conn, dataObjRenameInp->destDataObjInp.objPath,
89  0, NULL, &startTime, &endTime );
90  }
91 
92  return status;
93 }
94 
95 int
96 initCondForMv( dataObjCopyInp_t *dataObjRenameInp ) {
97  if ( dataObjRenameInp == NULL ) {
99  "initCondForMv: NULL dataObjRenameInp input" );
100  return USER__NULL_INPUT_ERR;
101  }
102 
103  memset( dataObjRenameInp, 0, sizeof( dataObjCopyInp_t ) );
104 
105  return 0;
106 }
107 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
True
#define True
Definition: parseCommandLine.h:11
DataObjCopyInp::srcDataObjInp
dataObjInp_t srcDataObjInp
Definition: dataObjCopy.h:26
rodsPath.h
DataObjCopyInp
Definition: dataObjCopy.h:25
rodsArguments_t
Definition: parseCommandLine.h:14
RodsPathInp
Definition: rodsPath.h:33
rodsArguments_t::verbose
int verbose
Definition: parseCommandLine.h:107
initCondForMv
int initCondForMv(dataObjCopyInp_t *dataObjRenameInp)
Definition: mvUtil.cpp:96
resolveRodsTarget
int resolveRodsTarget(rcComm_t *conn, rodsPathInp_t *rodsPathInp, int oprType)
Definition: miscUtil.cpp:2342
RENAME_COLL
#define RENAME_COLL
Definition: dataObjInpOut.h:178
rcGlobalExtern.h
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
RodsPath::objType
objType_t objType
Definition: rodsPath.h:19
RENAME_DATA_OBJ
#define RENAME_DATA_OBJ
Definition: dataObjInpOut.h:177
COLL_OBJ_T
@ COLL_OBJ_T
Definition: rodsType.h:39
RodsPathInp::targPath
rodsPath_t * targPath
Definition: rodsPath.h:37
MOVE_OPR
#define MOVE_OPR
Definition: dataObjInpOut.h:179
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
mvUtil.h
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
DataObjCopyInp::destDataObjInp
dataObjInp_t destDataObjInp
Definition: dataObjCopy.h:27
printTiming
int printTiming(rcComm_t *conn, char *objPath, rodsLong_t fileSize, char *localFile, struct timeval *startTime, struct timeval *endTime)
Definition: miscUtil.cpp:396
mvUtil
int mvUtil(rcComm_t *conn, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp)
Definition: mvUtil.cpp:14
rcDataObjRename
int rcDataObjRename(rcComm_t *conn, dataObjCopyInp_t *dataObjRenameInp)
Definition: rcDataObjRename.cpp:68
DataObjInp::oprType
int oprType
Definition: dataObjInpOut.h:72
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
rodsErrorTable.h
RodsPath
Definition: rodsPath.h:18
miscUtil.h
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
mvObjUtil
int mvObjUtil(rcComm_t *conn, char *srcPath, char *targPath, objType_t objType, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjRenameInp)
Definition: mvUtil.cpp:49
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
objType_t
objType_t
Definition: rodsType.h:36
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247