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)  

rsFileStat.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See fileStat.h for a description of this API call.*/
5 
6 #include "fileStat.h"
7 #include "miscServerFunct.hpp"
8 #include "rsFileStat.hpp"
9 
10 // =-=-=-=-=-=-=-
11 #include "irods_log.hpp"
12 #include "irods_file_object.hpp"
13 #include "irods_stacktrace.hpp"
15 
16 
17 int
18 rsFileStat( rsComm_t *rsComm, fileStatInp_t *fileStatInp,
19  rodsStat_t **fileStatOut ) {
21  int status;
22 
23  *fileStatOut = NULL;
24 
25  if( 0 == fileStatInp->rescId ) {
26  if( 0 == strlen(fileStatInp->rescHier) ) {
27  rodsLog(
28  LOG_ERROR,
29  "rsFileStat - rescId and rescHier are invalid");
31  }
33  fileStatInp->rescHier,
34  fileStatInp->rescId);
35  if( !ret.ok() ) {
36  irods::log(PASS(ret));
37  return ret.code();
38  }
39  }
40 
42  irods::error ret = resc_mgr.resolve(fileStatInp->rescId,resc);
43  if ( !ret.ok() ) {
44  irods::log(PASS(ret));
45  return ret.code();
46  }
47 
48  ret = resc->get_property<rodsServerHost_t*>(
51  if ( !ret.ok() ) {
52  irods::log(PASS(ret));
53  return ret.code();
54  }
55 
56  if ( rodsServerHost->localFlag < 0 ) {
57  return rodsServerHost->localFlag;
58  }
59  else {
60  status = rsFileStatByHost( rsComm, fileStatInp, fileStatOut,
62  return status;
63  }
64 }
65 
66 int
67 rsFileStatByHost( rsComm_t *rsComm, fileStatInp_t *fileStatInp,
68  rodsStat_t **fileStatOut, rodsServerHost_t *rodsServerHost ) {
69  int remoteFlag;
70  int status;
71 
72  if ( rodsServerHost == NULL ) {
74  "rsFileStatByHost: Input NULL rodsServerHost" );
76  }
77 
78  remoteFlag = rodsServerHost->localFlag;
79 
80  if ( remoteFlag == LOCAL_HOST ) {
81  status = _rsFileStat( rsComm, fileStatInp, fileStatOut );
82  }
83  else if ( remoteFlag == REMOTE_HOST ) {
84  status = remoteFileStat( rsComm, fileStatInp, fileStatOut,
86  }
87  else {
88  if ( remoteFlag < 0 ) {
89  return remoteFlag;
90  }
91  else {
93  "rsFileStat: resolveHost returned unrecognized value %d",
94  remoteFlag );
96  }
97  }
98 
99  /* Manually insert call-specific code here */
100 
101  return status;
102 }
103 
104 int
105 remoteFileStat( rsComm_t *rsComm, fileStatInp_t *fileStatInp,
106  rodsStat_t **fileStatOut, rodsServerHost_t *rodsServerHost ) {
107  int status;
108 
109  if ( rodsServerHost == NULL ) {
111  "remoteFileStat: Invalid rodsServerHost" );
113  }
114 
115  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
116  return status;
117  }
118 
119 
120  status = rcFileStat( rodsServerHost->conn, fileStatInp, fileStatOut );
121 
122  if ( status < 0 ) {
124  "remoteFileStat: rcFileStat failed for %s",
125  fileStatInp->fileName );
126  }
127 
128  return status;
129 }
130 
131 // =-=-=-=-=-=-=-
132 // local function to handle call to stat via resource plugin
134  rsComm_t* _comm,
135  fileStatInp_t* _stat_inp,
136  rodsStat_t** _stat_out ) {
137  struct stat myFileStat;
138  memset( &myFileStat, 0, sizeof( myFileStat ) );
139 
140  // =-=-=-=-=-=-=-
141  // make call to stat via resource plugin
142  irods::file_object_ptr file_obj(
143  new irods::file_object(
144  _comm,
145  _stat_inp->objPath,
146  _stat_inp->fileName,
147  _stat_inp->rescId,
148  0, 0, 0 ) );
149  irods::error stat_err = fileStat( _comm, file_obj, &myFileStat );
150 
151  // =-=-=-=-=-=-=-
152  // log error if necessary
153  if ( !stat_err.ok() ) {
154 // irods::log(LOG_ERROR, stat_err.result());
155  return stat_err.code();
156  }
157 
158  // =-=-=-=-=-=-=-
159  // convert unix stat struct to an irods stat struct
160  *_stat_out = ( rodsStat_t* )malloc( sizeof( rodsStat_t ) );
161  int status = statToRodsStat( *_stat_out, &myFileStat );
162 
163  // =-=-=-=-=-=-=-
164  // manage error if necessary
165  if ( status < 0 ) {
166  free( *_stat_out );
167  *_stat_out = NULL;
168  }
169 
170  return status;
171 
172 } // _rsFileStat
remoteFileStat
int remoteFileStat(rsComm_t *rsComm, fileStatInp_t *fileStatInp, rodsStat_t **fileStatOut, rodsServerHost_t *rodsServerHost)
Definition: rsFileStat.cpp:105
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
_rsFileStat
int _rsFileStat(rsComm_t *_comm, fileStatInp_t *_stat_inp, rodsStat_t **_stat_out)
Definition: rsFileStat.cpp:133
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
fileStatInp_t
Definition: fileStat.h:7
rsFileStatByHost
int rsFileStatByHost(rsComm_t *rsComm, fileStatInp_t *fileStatInp, rodsStat_t **fileStatOut, rodsServerHost_t *rodsServerHost)
Definition: rsFileStat.cpp:67
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
irods_resource_backport.hpp
fileStat.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
rsFileStat
int rsFileStat(rsComm_t *rsComm, fileStatInp_t *fileStatInp, rodsStat_t **fileStatOut)
Definition: rsFileStat.cpp:18
statToRodsStat
int statToRodsStat(rodsStat_t *rodsStat, struct stat *myFileStat)
Definition: rcMisc.cpp:280
rsFileStat.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rodsStat
Definition: rodsType.h:52
fileStatInp_t::rescHier
char rescHier[(1024+64)]
Definition: fileStat.h:10
fileStatInp_t::objPath
char objPath[(1024+64)]
Definition: fileStat.h:11
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
fileStatInp_t::rescId
rodsLong_t rescId
Definition: fileStat.h:12
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileStat
irods::error fileStat(rsComm_t *, irods::first_class_object_ptr, struct stat *)
Definition: fileDriver.cpp:207
irods::resource_manager::hier_to_leaf_id
error hier_to_leaf_id(const std::string &, rodsLong_t &)
Definition: irods_resource_manager.cpp:1082
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
fileStatInp_t::fileName
char fileName[(1024+64)]
Definition: fileStat.h:9
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::RESOURCE_HOST
const std::string RESOURCE_HOST("resource_property_host")
irods_log.hpp
rcFileStat
int rcFileStat(rcComm_t *conn, fileStatInp_t *fileStatInp, rodsStat_t **fileStatOut)
Definition: rcFileStat.cpp:24