00001
00002
00003 #include "subStructFileStat.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010 #include "eirods_stacktrace.h"
00011
00012
00013
00014 int
00015 rsSubStructFileStat (rsComm_t *rsComm, subFile_t *subFile, rodsStat_t **subStructFileStatOut)
00016 {
00017 rodsServerHost_t *rodsServerHost;
00018 int remoteFlag;
00019 int status;
00020 remoteFlag = resolveHost (&subFile->addr, &rodsServerHost);
00021
00022 if (remoteFlag == LOCAL_HOST) {
00023 status = _rsSubStructFileStat (rsComm, subFile, subStructFileStatOut);
00024 } else if (remoteFlag == REMOTE_HOST) {
00025 status = remoteSubStructFileStat (rsComm, subFile, subStructFileStatOut,
00026 rodsServerHost);
00027 } else {
00028 if (remoteFlag < 0) {
00029 return (remoteFlag);
00030 } else {
00031 rodsLog (LOG_NOTICE,
00032 "rsSubStructFileStat: resolveHost returned unrecognized value %d",
00033 remoteFlag);
00034 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00035 }
00036 }
00037
00038 return (status);
00039 }
00040
00041 int
00042 remoteSubStructFileStat (rsComm_t *rsComm, subFile_t *subFile,
00043 rodsStat_t **subStructFileStatOut, rodsServerHost_t *rodsServerHost)
00044 {
00045 int status;
00046
00047 if (rodsServerHost == NULL) {
00048 rodsLog (LOG_NOTICE,
00049 "remoteSubStructFileStat: Invalid rodsServerHost");
00050 return SYS_INVALID_SERVER_HOST;
00051 }
00052
00053 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00054 return status;
00055 }
00056
00057 status = rcSubStructFileStat (rodsServerHost->conn, subFile, subStructFileStatOut);
00058
00059 if (status < 0 && getErrno (status) != ENOENT) {
00060 rodsLog (LOG_NOTICE,
00061 "remoteSubStructFileStat: rcSubStructFileStat failed for %s, status = %d",
00062 subFile->subFilePath, status);
00063 }
00064
00065 return status;
00066 }
00067
00068 int _rsSubStructFileStat( rsComm_t* _comm,
00069 subFile_t* _sub_file,
00070 rodsStat_t** _stat_out ) {
00071
00072
00073 eirods::structured_object_ptr struct_obj(
00074 new eirods::structured_object(
00075 *_sub_file ) );
00076 struct_obj->comm( _comm );
00077 struct_obj->resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00078
00079
00080
00081
00082 struct stat my_stat;
00083 eirods::error stat_err = fileStat( _comm, struct_obj, &my_stat );
00084
00085 if( !stat_err.ok() ) {
00086
00087 #if 0
00088 std::stringstream msg;
00089 msg << "_rsSubStructFileStat - failed on call to fileStat for [";
00090 msg << struct_obj.physical_path();
00091 msg << "]";
00092 eirods::log( PASS( false, -1, msg.str(), stat_err ) );
00093 #endif
00094 return stat_err.code();
00095
00096 } else {
00097
00098
00099
00100 *_stat_out = new rodsStat_t;
00101 int status = statToRodsStat( *_stat_out, &my_stat );
00102
00103
00104
00105 if( status < 0 ) {
00106 delete (*_stat_out);
00107 *_stat_out = NULL;
00108 }
00109
00110 return status;
00111
00112 }
00113
00114 }
00115