13 #include <boost/filesystem/operations.hpp>
14 #include <boost/filesystem/convenience.hpp>
16 using namespace boost::filesystem;
22 const char * hostname ) {
24 if ( rodsPathInp->
numSrc != 1 ) {
25 rodsLog(
LOG_ERROR,
"scanObj: gave %i input source path, should give one and only one", rodsPathInp->
numSrc );
38 if ( is_symlink(
p ) ) {
43 snprintf( inpPath,
sizeof( inpPath ),
"%s", inpPathO );
45 if ( is_directory(
p ) ) {
48 "subdirectories to be scanned is declared as being "
49 "used for a mounted collection: abort!", inpPath );
53 return scanObjDir( conn, myRodsArgs, inpPath, hostname );
57 return scanObjCol( conn, myRodsArgs, inpPathO );
71 path srcDirPath( inpPath );
72 if ( is_symlink( srcDirPath ) ) {
76 else if ( !is_directory( srcDirPath ) ) {
84 int return_status = 0;
85 directory_iterator end_itr;
86 for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
87 path cp = itr->path();
90 if ( is_symlink( cp ) ) {
94 else if ( is_directory( cp ) ) {
106 return return_status;
118 const char *lastPart = strrchr( inpPath,
'/' ) + 1;
119 strncpy( firstPart, inpPath, strlen( inpPath ) - strlen( lastPart ) - 1 );
120 memset( &genQueryInp1, 0,
sizeof( genQueryInp1 ) );
139 memset( &genQueryInp2, 0,
sizeof( genQueryInp2 ) );
151 snprintf( condStr2,
MAX_NAME_LEN,
"like '%s%s'", inpPath,
"%" );
171 printf(
"Could not find the requested data object or collection in iRODS.\n" );
175 && genQueryOut2->continueInx > 0)
177 genQueryInp2.
continueInx = genQueryOut2->continueInx;
194 int rcPriv = 0, rcStat = 0, rcOther = 0;
196 for (
int i = 0; i < genQueryOut2->
rowCnt; i++ ) {
204 if ( dataPathStruct ==
NULL || dataSizeStruct ==
NULL || locStruct ==
NULL ||
205 zoneStruct ==
NULL || dataNameStruct ==
NULL || collNameStruct ==
NULL ||
206 rescIDStruct ==
NULL ) {
207 printf(
"getSqlResultByInx returned null in statPhysFile." );
211 char *dataPath = &dataPathStruct->
value[dataPathStruct->
len * i];
212 char *loc = &locStruct->
value[locStruct->
len * i];
213 char *zone = &zoneStruct->
value[zoneStruct->
len * i];
214 char *dataName = &dataNameStruct->
value[dataNameStruct->
len * i];
215 char *collName = &collNameStruct->
value[collNameStruct->
len * i];
216 char *rescID = &rescIDStruct->
value[rescIDStruct->
len * i];
223 fileStatInp.
rescId = strtoll( rescID, 0, 0 );
224 snprintf( fileStatInp.
objPath,
sizeof( fileStatInp.
objPath ),
"%s/%s", collName, dataName );
228 printf(
"User must be a rodsadmin to scan iRODS data objects.\n" );
233 printf(
"Physical file %s on server %s is missing, corresponding to "
234 "iRODS object %s/%s\n", dataPath, loc, collName, dataName );
246 if (rcPriv != 0) {
return rcPriv; }
247 else if (rcStat != 0) {
return rcStat; }
248 else if (rcOther!= 0) {
return rcOther; }
260 memset( &genQueryInp, 0,
sizeof( genQueryInp ) );
274 snprintf( condStr,
MAX_NAME_LEN,
"like '%s%%' || ='%s'", hostname, hostname );
279 printf(
"%s is not registered in iRODS\n", inpPath );
291 int i, minLen,
status, status1;
296 memset( &genQueryInp, 0,
sizeof( genQueryInp ) );
300 snprintf( condStr,
MAX_NAME_LEN,
"='%s'",
"mountPoint" );
303 status1 =
rcGenQuery( conn, &genQueryInp, &genQueryOut );
309 for ( i = 0; i < genQueryOut->
rowCnt; i++ ) {
312 if ( strlen( dirMPath ) <= strlen( inpPath ) ) {
313 minLen = strlen( dirMPath );
316 minLen = strlen( inpPath );
318 if ( strncmp( dirMPath, inpPath, minLen ) == 0 ) {