14 #include <boost/filesystem/operations.hpp>
15 #include <boost/filesystem/convenience.hpp>
20 using namespace boost::filesystem;
28 if ( rodsPathInp->
numSrc != 1 ) {
30 "should give one and only one", rodsPathInp->
numSrc );
41 if ( is_symlink(
p ) ) {
45 int lenInpPath = strlen( inpPathO );
46 if ( lenInpPath > 0 &&
'/' == inpPathO[ lenInpPath - 1 ] ) {
56 strncpy( inpPath, inpPathO, lenInpPath );
57 inpPath[ lenInpPath ] =
'\0';
59 if ( is_directory(
p ) ) {
62 "subdirectories to be checked is declared as being "
63 "used for a mounted collection: abort!", inpPath );
67 return fsckObjDir( conn, myRodsArgs, inpPath, strategy, argument_for_SetGenQueryInpFromPhysicalPath );
75 path srcDirPath( inpPath );
76 if ( is_symlink( srcDirPath ) ) {
78 }
else if ( is_directory( srcDirPath ) ) {
83 directory_iterator end_itr;
84 for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
85 path cp = itr->path();
88 if ( is_symlink( cp ) ) {
92 else if ( is_directory( cp ) ) {
94 const int tmp_status =
fsckObjDir( conn, myRodsArgs, fullPath, strategy, argument_for_SetGenQueryInpFromPhysicalPath );
101 const int tmp_status =
chkObjConsistency( conn, myRodsArgs, fullPath, strategy, argument_for_SetGenQueryInpFromPhysicalPath );
113 const path
p(inpPath);
114 if ( is_symlink(
p ) ) {
117 const intmax_t srcSize = file_size(
p);
119 strategy(&genQueryInp, inpPath, argument_for_SetGenQueryInpFromPhysicalPath);
128 intmax_t objSize = 0;
133 catch (
const std::invalid_argument&
e) {
134 std::cerr <<
"ERROR: could not parse object size into integer [exception => " <<
e.what() <<
", path => " << inpPath <<
"].\n";
137 catch (
const std::out_of_range&
e) {
138 std::cerr <<
"ERROR: could not parse object size into integer [exception => " <<
e.what() <<
", path => " << inpPath <<
"].\n";
143 if ( srcSize == objSize ) {
145 if ( strcmp( objChksum,
"" ) != 0 ) {
148 printf(
"CORRUPTION: local file [%s] checksum not consistent with iRODS object [%s/%s] checksum.\n", inpPath, objPath, objName );
150 printf(
"ERROR chkObjConsistency: verifyChksumLocFile failed: status [%d] file [%s] objPath [%s] objName [%s] objChksum [%s]\n",
status, inpPath, objPath, objName, objChksum);
153 printf(
"WARNING: checksum not available for iRODS object [%s/%s], no checksum comparison possible with local file [%s] .\n", objPath, objName, inpPath );
157 printf(
"CORRUPTION: local file [%s] size [%ji] not consistent with iRODS object [%s/%s] size [%ji].\n", inpPath, srcSize, objPath, objName, objSize );
161 printf(
"ERROR chkObjConsistency: rcGenQuery failed: status [%d] genQueryOut [%p] file [%s]\n",
status, genQueryOut, inpPath);