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)  

rsFileTruncate.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See fileTruncate.h for a description of this API call.*/
5 
6 #include "fileTruncate.h"
7 #include "miscServerFunct.hpp"
8 #include "rsFileTruncate.hpp"
9 
10 // =-=-=-=-=-=-=-
11 #include "irods_log.hpp"
12 #include "irods_file_object.hpp"
13 #include "irods_stacktrace.hpp"
15 
16 int
17 rsFileTruncate( rsComm_t *rsComm, fileOpenInp_t *fileTruncateInp ) {
19  int remoteFlag;
20  int status;
21 
22  //remoteFlag = resolveHost (&fileTruncateInp->addr, &rodsServerHost);
23  irods::error ret = irods::get_host_for_hier_string( fileTruncateInp->resc_hier_, remoteFlag, rodsServerHost );
24  if ( !ret.ok() ) {
25  irods::log( PASSMSG( " failed in call to irods::get_host_for_hier_string", ret ) );
26  return -1;
27  }
28  if ( remoteFlag == LOCAL_HOST ) {
29  status = _rsFileTruncate( rsComm, fileTruncateInp );
30  }
31  else if ( remoteFlag == REMOTE_HOST ) {
32  status = remoteFileTruncate( rsComm, fileTruncateInp, rodsServerHost );
33  }
34  else {
35  if ( remoteFlag < 0 ) {
36  return remoteFlag;
37  }
38  else {
40  "rsFileTruncate: resolveHost returned unrecognized value %d",
41  remoteFlag );
43  }
44  }
45 
46  /* Manually insert call-specific code here */
47 
48  return status;
49 }
50 
51 int
52 remoteFileTruncate( rsComm_t *rsComm, fileOpenInp_t *fileTruncateInp,
54  int status;
55 
56  if ( rodsServerHost == NULL ) {
58  "remoteFileTruncate: Invalid rodsServerHost" );
60  }
61 
62  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
63  return status;
64  }
65 
66 
67  status = rcFileTruncate( rodsServerHost->conn, fileTruncateInp );
68 
69  if ( status < 0 ) {
71  "remoteFileTruncate: rcFileTruncate failed for %s, status = %d",
72  fileTruncateInp->fileName, status );
73  }
74 
75  return status;
76 }
77 
78 // =-=-=-=-=-=-=-
79 // local function which makes the call to truncate via the resource plugin
81  rsComm_t* _comm,
82  fileOpenInp_t* _trunc_inp ) {
83  // =-=-=-=-=-=-=-
84  // make the call to rename via the resource plugin
85  irods::file_object_ptr file_obj(
87  _comm,
88  _trunc_inp->objPath,
89  _trunc_inp->fileName,
90  _trunc_inp->resc_hier_,
91  0, 0, 0 ) );
92  file_obj->size( _trunc_inp->dataSize );
93 
94  // =-=-=-=-=-=-=-
95  // pass condInput
96  file_obj->cond_input( _trunc_inp->condInput );
97 
98  irods::error trunc_err = fileTruncate( _comm, file_obj );
99 
100  // =-=-=-=-=-=-=-
101  // report errors if any
102  if ( !trunc_err.ok() ) {
103  std::stringstream msg;
104  msg << "fileTruncate for [";
105  msg << _trunc_inp->fileName;
106  msg << "]";
107  msg << trunc_err.code();
108  irods::error err = PASSMSG( msg.str(), trunc_err );
109  irods::log( err );
110  }
111 
112  return trunc_err.code();
113 
114 } // _rsFileTruncate
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
_rsFileTruncate
int _rsFileTruncate(rsComm_t *_comm, fileOpenInp_t *_trunc_inp)
Definition: rsFileTruncate.cpp:80
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
rsFileTruncate.hpp
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
irods_resource_backport.hpp
fileOpenInp_t::resc_hier_
char resc_hier_[(1024+64)]
Definition: fileOpen.h:16
rsFileTruncate
int rsFileTruncate(rsComm_t *rsComm, fileOpenInp_t *fileTruncateInp)
Definition: rsFileTruncate.cpp:17
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
remoteFileTruncate
int remoteFileTruncate(rsComm_t *rsComm, fileOpenInp_t *fileTruncateInp, rodsServerHost_t *rodsServerHost)
Definition: rsFileTruncate.cpp:52
fileOpenInp_t::fileName
char fileName[(1024+64)]
Definition: fileOpen.h:20
irods::error::code
long long code() const
Definition: irods_error.cpp:194
fileOpenInp_t::objPath
char objPath[(1024+64)]
Definition: fileOpen.h:17
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
fileTruncate.h
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
rcFileTruncate
int rcFileTruncate(rcComm_t *conn, fileOpenInp_t *fileTruncateInp)
Definition: rcFileTruncate.cpp:23
irods::log
void log(const error &)
Definition: irods_log.cpp:13
fileTruncate
irods::error fileTruncate(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:514
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileOpenInp_t::condInput
keyValPair_t condInput
Definition: fileOpen.h:24
fileOpenInp_t
Definition: fileOpen.h:14
fileOpenInp_t::dataSize
rodsLong_t dataSize
Definition: fileOpen.h:23
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
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_log.hpp