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)  

rsFileGet.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See fileGet.h for a description of this API call.*/
5 
6 #include "fileGet.h"
7 #include "miscServerFunct.hpp"
8 #include "rsFileGet.hpp"
9 #include "rsFileOpen.hpp"
10 
11 #include "irods_log.hpp"
12 #include "irods_file_object.hpp"
14 
15 
16 /* rsFileGet - Get the content of a small file into a single buffer
17  * in fileGetOutBBuf->buf.
18  * Return value - int - number of bytes read.
19  */
20 
21 int
22 rsFileGet( rsComm_t *rsComm, fileOpenInp_t *fileGetInp,
23  bytesBuf_t *fileGetOutBBuf ) {
25  int remoteFlag;
26  int status;
27 
28  //remoteFlag = resolveHost (&fileGetInp->addr, &rodsServerHost);
30  if ( !ret.ok() ) {
31  irods::log( PASSMSG( "failed in call to irods::get_host_for_hier_string", ret ) );
32  return -1;
33  }
34  if ( remoteFlag == LOCAL_HOST ) {
35  status = _rsFileGet( rsComm, fileGetInp, fileGetOutBBuf );
36  }
37  else if ( remoteFlag == REMOTE_HOST ) {
38  status = remoteFileGet( rsComm, fileGetInp, fileGetOutBBuf,
40  }
41  else {
42  if ( remoteFlag < 0 ) {
43  return remoteFlag;
44  }
45  else {
47  "rsFileGet: resolveHost returned unrecognized value %d",
48  remoteFlag );
50  }
51  }
52 
53  return status;
54 }
55 
56 int
57 remoteFileGet( rsComm_t *rsComm, fileOpenInp_t *fileGetInp,
58  bytesBuf_t *fileGetOutBBuf, rodsServerHost_t *rodsServerHost ) {
59  int status;
60 
61  if ( rodsServerHost == NULL ) {
63  "remoteFileGet: Invalid rodsServerHost" );
65  }
66 
67  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
68  return status;
69  }
70 
71 
72 
73  status = rcFileGet( rodsServerHost->conn, fileGetInp, fileGetOutBBuf );
74 
75  if ( status < 0 ) {
77  "remoteFileGet: rcFileGet failed for %s",
78  fileGetInp->fileName );
79  }
80 
81  return status;
82 }
83 
85  rsComm_t* _comm,
86  fileOpenInp_t* _get_inp,
87  bytesBuf_t* _get_buf ) {
88 
89  int fd;
90  int len;
91 
92  len = _get_inp->dataSize;
93  fd = _rsFileOpen( _comm, _get_inp );
94 
95  if ( fd < 0 ) {
97  "_rsFileGet: fileGet for %s, status = %d",
98  _get_inp->fileName, fd );
99  return fd;
100  }
101 
102  if ( _get_buf->buf == NULL ) {
103  _get_buf->buf = malloc( len );
104  }
105 
106  irods::file_object_ptr file_obj(
107  new irods::file_object(
108  _comm,
109  _get_inp->objPath,
110  _get_inp->fileName,
111  _get_inp->resc_hier_,
112  fd,
113  _get_inp->mode,
114  _get_inp->flags ) );
115 
116  // =-=-=-=-=-=-=-
117  // pass condInput
118  file_obj->cond_input( _get_inp->condInput );
119 
120  irods::error read_err = fileRead( _comm,
121  file_obj,
122  _get_buf->buf,
123  len );
124  int bytes_read = read_err.code();
125  if ( bytes_read != len ) {
126  if ( bytes_read >= 0 ) {
127 
128  _get_buf->len = bytes_read;
129 
130  }
131  else {
132  std::stringstream msg;
133  msg << "fileRead failed for [";
134  msg << _get_inp->fileName;
135  msg << "]";
136  irods::error ret_err = PASSMSG( msg.str(), read_err );
137  irods::log( ret_err );
138  }
139  }
140  else {
141  _get_buf->len = bytes_read;
142  }
143 
144  // =-=-=-=-=-=-=-
145  // call resource plugin close
146  irods::error close_err = fileClose( _comm,
147  file_obj );
148  if ( !close_err.ok() ) {
149  irods::error err = PASSMSG( "error on close", close_err );
150  irods::log( err );
151  }
152 
153  return bytes_read;
154 
155 } // _rsFileGet
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
rsFileOpen.hpp
remoteFileGet
int remoteFileGet(rsComm_t *rsComm, fileOpenInp_t *fileGetInp, bytesBuf_t *fileGetOutBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsFileGet.cpp:57
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
_rsFileGet
int _rsFileGet(rsComm_t *_comm, fileOpenInp_t *_get_inp, bytesBuf_t *_get_buf)
Definition: rsFileGet.cpp:84
irods_file_object.hpp
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
fileGet.h
irods_resource_backport.hpp
fileOpenInp_t::resc_hier_
char resc_hier_[(1024+64)]
Definition: fileOpen.h:16
rsFileGet
int rsFileGet(rsComm_t *rsComm, fileOpenInp_t *fileGetInp, bytesBuf_t *fileGetOutBBuf)
Definition: rsFileGet.cpp:22
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileOpenInp_t::fileName
char fileName[(1024+64)]
Definition: fileOpen.h:20
BytesBuf::len
int len
Definition: rodsDef.h:198
irods::error::code
long long code() const
Definition: irods_error.cpp:194
fileOpenInp_t::flags
int flags
Definition: fileOpen.h:21
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
_rsFileOpen
int _rsFileOpen(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp)
Definition: rsFileOpen.cpp:114
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
fileOpenInp_t::mode
int mode
Definition: fileOpen.h:22
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
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileClose
irods::error fileClose(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:147
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
rsFileGet.hpp
rcFileGet
int rcFileGet(rcComm_t *conn, fileOpenInp_t *fileGetInp, bytesBuf_t *fileGetOutBBuf)
Definition: rcFileGet.cpp:24
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_log.hpp
fileRead
irods::error fileRead(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:81