00001
00002
00003 #include "subStructFileRmdir.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010
00011
00012 int
00013 rsSubStructFileRmdir (rsComm_t *rsComm, subFile_t *subFile)
00014 {
00015 rodsServerHost_t *rodsServerHost;
00016 int remoteFlag;
00017 int fd;
00018
00019 remoteFlag = resolveHost (&subFile->addr, &rodsServerHost);
00020
00021 if (remoteFlag == LOCAL_HOST) {
00022 fd = _rsSubStructFileRmdir (rsComm, subFile);
00023 } else if (remoteFlag == REMOTE_HOST) {
00024 fd = remoteSubStructFileRmdir (rsComm, subFile, rodsServerHost);
00025 } else {
00026 if (remoteFlag < 0) {
00027 return (remoteFlag);
00028 } else {
00029 rodsLog (LOG_NOTICE,
00030 "rsSubStructFileRmdir: resolveHost returned unrecognized value %d",
00031 remoteFlag);
00032 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00033 }
00034 }
00035
00036 return (fd);
00037 }
00038
00039 int
00040 remoteSubStructFileRmdir (rsComm_t *rsComm, subFile_t *subFile,
00041 rodsServerHost_t *rodsServerHost)
00042 {
00043 int fd;
00044 int status;
00045
00046 if (rodsServerHost == NULL) {
00047 rodsLog (LOG_NOTICE,
00048 "remoteSubStructFileRmdir: Invalid rodsServerHost");
00049 return SYS_INVALID_SERVER_HOST;
00050 }
00051
00052 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00053 return status;
00054 }
00055
00056 fd = rcSubStructFileRmdir (rodsServerHost->conn, subFile);
00057
00058 if (fd < 0) {
00059 rodsLog (LOG_NOTICE,
00060 "remoteSubStructFileRmdir: rcSubStructFileRmdir failed for %s, status = %d",
00061 subFile->subFilePath, fd);
00062 }
00063
00064 return fd;
00065 }
00066
00067 int _rsSubStructFileRmdir( rsComm_t* _comm,
00068 subFile_t* _sub_file ) {
00069
00070
00071 eirods::structured_object_ptr struct_obj(
00072 new eirods::structured_object(
00073 *_sub_file ) );
00074 struct_obj->comm( _comm );
00075 struct_obj->resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00076
00077
00078
00079 eirods::error rmdir_err = fileRmdir( _comm, struct_obj );
00080 if( !rmdir_err.ok() ) {
00081 std::stringstream msg;
00082 msg << "failed on call to fileRmdir for [";
00083 msg << struct_obj->physical_path();
00084 msg << "]";
00085 eirods::log( PASSMSG( msg.str(), rmdir_err ) );
00086 return rmdir_err.code();
00087
00088 } else {
00089 return rmdir_err.code();
00090
00091 }
00092
00093 }
00094