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)  

rsFileGetFsFreeSpace.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See fileGetFsFreeSpace.h for a description of this API call.*/
5 
6 #include "fileGetFsFreeSpace.h"
7 #include "miscServerFunct.hpp"
9 
10 // =-=-=-=-=-=-=-
11 #include "irods_log.hpp"
12 #include "irods_file_object.hpp"
13 #include "irods_stacktrace.hpp"
15 
16 int
18  fileGetFsFreeSpaceInp_t *fileGetFsFreeSpaceInp,
19  fileGetFsFreeSpaceOut_t **fileGetFsFreeSpaceOut ) {
21  int remoteFlag;
22  int status;
23 
24  *fileGetFsFreeSpaceOut = NULL;
25 
26  //remoteFlag = resolveHost (&fileGetFsFreeSpaceInp->addr, &rodsServerHost);
27  irods::error ret = irods::get_host_for_hier_string( fileGetFsFreeSpaceInp->rescHier, remoteFlag, rodsServerHost );
28  if ( !ret.ok() ) {
29  irods::log( PASSMSG( "failed in call to irods::get_host_for_hier_string", ret ) );
30  return -1;
31  }
32  if ( remoteFlag == LOCAL_HOST ) {
33  status = _rsFileGetFsFreeSpace( rsComm, fileGetFsFreeSpaceInp,
34  fileGetFsFreeSpaceOut );
35  }
36  else if ( remoteFlag == REMOTE_HOST ) {
37  status = remoteFileGetFsFreeSpace( rsComm, fileGetFsFreeSpaceInp,
38  fileGetFsFreeSpaceOut, rodsServerHost );
39  }
40  else {
41  if ( remoteFlag < 0 ) {
42  return remoteFlag;
43  }
44  else {
46  "rsFileGetFsFreeSpace: resolveHost returned unrecognized value %d",
47  remoteFlag );
49  }
50  }
51 
52  /* Manually insert call-specific code here */
53 
54  return status;
55 }
56 
57 int
59  fileGetFsFreeSpaceInp_t *fileGetFsFreeSpaceInp,
60  fileGetFsFreeSpaceOut_t **fileGetFsFreeSpaceOut,
62  int status;
63 
64  if ( rodsServerHost == NULL ) {
66  "remoteFileGetFsFreeSpace: Invalid rodsServerHost" );
68  }
69 
70  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
71  return status;
72  }
73 
74 
75  status = rcFileGetFsFreeSpace( rodsServerHost->conn, fileGetFsFreeSpaceInp,
76  fileGetFsFreeSpaceOut );
77 
78  if ( status < 0 ) {
80  "remoteFileGetFsFreeSpace: rcFileGetFsFreeSpace failed for %s, status = %d",
81  fileGetFsFreeSpaceInp->fileName, status );
82  }
83 
84  return status;
85 }
86 
87 // =-=-=-=-=-=-=-
88 // local function to make call to freespace via resource plugin
90  rsComm_t* _comm,
91  fileGetFsFreeSpaceInp_t* _freespace_inp,
92  fileGetFsFreeSpaceOut_t** _freespace_out ) {
93  // =-=-=-=-=-=-=-
94  //
95  if ( _freespace_inp->objPath[0] == '\0' ) {
96  std::stringstream msg;
97  msg << __FUNCTION__;
98  msg << " - Empty logical path.";
99  irods::log( LOG_ERROR, msg.str() );
101  }
102 
103  // =-=-=-=-=-=-=-
104  // make call to freespace via resource plugin
105  irods::file_object_ptr file_obj(
106  new irods::file_object(
107  _comm,
108  _freespace_inp->objPath,
109  _freespace_inp->fileName,
110  _freespace_inp->rescHier,
111  0, 0,
112  _freespace_inp->flag ) );
113 
114  irods::error free_err = fileGetFsFreeSpace( _comm, file_obj );
115  // =-=-=-=-=-=-=-
116  // handle errors if any
117  if ( !free_err.ok() ) {
118  std::stringstream msg;
119  msg << "fileGetFsFreeSpace failed for [";
120  msg << _freespace_inp->fileName;
121  msg << "]";
122  irods::error err = PASSMSG( msg.str(), free_err );
123  irods::log( err );
124  return ( int ) free_err.code();
125  }
126 
127  // =-=-=-=-=-=-=-
128  // otherwise its a success, set size appropriately
129  *_freespace_out = ( fileGetFsFreeSpaceOut_t* )malloc( sizeof( fileGetFsFreeSpaceOut_t ) );
130  ( *_freespace_out )->size = free_err.code();
131 
132  return 0;
133 
134 } // _rsFileGetFsFreeSpace
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
rcFileGetFsFreeSpace
int rcFileGetFsFreeSpace(rcComm_t *conn, fileGetFsFreeSpaceInp_t *fileGetFsFreeSpaceInp, fileGetFsFreeSpaceOut_t **fileGetFsFreeSpaceOut)
Definition: rcFileGetFsFreeSpace.cpp:24
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
fileGetFsFreeSpaceInp_t
Definition: fileGetFsFreeSpace.h:7
fileGetFsFreeSpace.h
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
fileGetFsFreeSpaceInp_t::rescHier
char rescHier[(1024+64)]
Definition: fileGetFsFreeSpace.h:10
irods_file_object.hpp
irods_stacktrace.hpp
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
irods_resource_backport.hpp
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
remoteFileGetFsFreeSpace
int remoteFileGetFsFreeSpace(rsComm_t *rsComm, fileGetFsFreeSpaceInp_t *fileGetFsFreeSpaceInp, fileGetFsFreeSpaceOut_t **fileGetFsFreeSpaceOut, rodsServerHost_t *rodsServerHost)
Definition: rsFileGetFsFreeSpace.cpp:58
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
fileGetFsFreeSpaceInp_t::flag
int flag
Definition: fileGetFsFreeSpace.h:12
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
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
fileGetFsFreeSpace
irods::error fileGetFsFreeSpace(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:484
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
rsFileGetFsFreeSpace
int rsFileGetFsFreeSpace(rsComm_t *rsComm, fileGetFsFreeSpaceInp_t *fileGetFsFreeSpaceInp, fileGetFsFreeSpaceOut_t **fileGetFsFreeSpaceOut)
Definition: rsFileGetFsFreeSpace.cpp:17
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
fileGetFsFreeSpaceInp_t::fileName
char fileName[(1024+64)]
Definition: fileGetFsFreeSpace.h:9
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
_rsFileGetFsFreeSpace
int _rsFileGetFsFreeSpace(rsComm_t *_comm, fileGetFsFreeSpaceInp_t *_freespace_inp, fileGetFsFreeSpaceOut_t **_freespace_out)
Definition: rsFileGetFsFreeSpace.cpp:89
fileGetFsFreeSpaceOut_t
Definition: fileGetFsFreeSpace.h:16
fileGetFsFreeSpaceInp_t::objPath
char objPath[(1024+64)]
Definition: fileGetFsFreeSpace.h:11
fileGetFsFreeSpaceOut_t::size
rodsLong_t size
Definition: fileGetFsFreeSpace.h:17
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_log.hpp
rsFileGetFsFreeSpace.hpp