Skip to content

Commit a6a7da7

Browse files
committed
Clang fix
1 parent 9ed7ef0 commit a6a7da7

File tree

2 files changed

+61
-63
lines changed

2 files changed

+61
-63
lines changed

src/Core/Services/FileTransferClient.cc

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -47,15 +47,15 @@ FileTransferClient::~FileTransferClient()
4747
if (tempdir_ != "") tfm_->delete_tempdir(tempdir_);
4848
tempdir_ = "";
4949
}
50-
50+
5151

5252
bool FileTransferClient::open(IComAddressHandle address, std::string servicename, int session, std::string passwd)
5353
{
5454
if(!(ServiceClient::open(address,servicename,session,passwd)))
5555
{
5656
return(false);
5757
}
58-
58+
5959
IComPacketHandle packet;
6060
// The next function will create the packet
6161
if (!(recv(packet)))
@@ -74,7 +74,7 @@ bool FileTransferClient::open(IComAddressHandle address, std::string servicename
7474
{
7575
buffersize_ = packet->getparam1();
7676
std::vector<std::string> data = packet->getvector();
77-
77+
7878
remote_homedirid_ = data[0];
7979
remote_scirun_tempdir_ = data[1];
8080

@@ -95,7 +95,7 @@ bool FileTransferClient::create_remote_tempdir(std::string pattern,std::string &
9595
{
9696
seterror("Could not create IComPacket");
9797
tempdir = "";
98-
return(false);
98+
return(false);
9999
}
100100
packet->settag(TAG_TDIR);
101101
packet->setstring(pattern);
@@ -132,11 +132,11 @@ bool FileTransferClient::create_local_tempdir(std::string pattern,std::string &t
132132
return(tfm_->create_tempdir(pattern,tempdir));
133133
}
134134

135-
135+
136136
bool FileTransferClient::get_local_homedirid(std::string& homeid)
137137
{
138138
homeid = local_homedirid_;
139-
if (homeid == "")
139+
if (homeid == "")
140140
{
141141
local_homedirid_ = tfm_->get_homedirID();
142142
homeid = local_homedirid_;
@@ -155,7 +155,7 @@ bool FileTransferClient::get_remote_homedirid(std::string& homeid)
155155
bool FileTransferClient::get_local_scirun_tempdir(std::string& tempdir)
156156
{
157157
tempdir = local_scirun_tempdir_;
158-
if (tempdir == "")
158+
if (tempdir == "")
159159
{
160160
local_scirun_tempdir_ = tfm_->get_scirun_tmp_dir();
161161
tempdir = local_scirun_tempdir_;
@@ -177,7 +177,7 @@ bool FileTransferClient::translate_scirun_tempdir(std::string& tempdir)
177177
{
178178
size_t rt = remote_scirun_tempdir_.size();
179179
size_t lt = local_scirun_tempdir_.size();
180-
180+
181181
if (rt > lt)
182182
{
183183
if (tempdir.substr(0,rt) == remote_scirun_tempdir_)
@@ -211,27 +211,27 @@ bool FileTransferClient::translate_scirun_tempdir(std::string& tempdir)
211211
return(true);
212212
}
213213
}
214-
214+
215215
bool FileTransferClient::get_file(std::string remotefilename,std::string localfilename)
216216
{
217217
FILE* localfile;
218218
int fileid = fileidcnt_++;
219-
219+
220220
localfile = ::fopen(localfilename.c_str(),"w");
221221
if (localfile == 0)
222222
{
223223
seterror("Could not open local filename");
224224
return(false);
225225
}
226-
226+
227227
IComPacketHandle packet(new IComPacket);
228228
if (!packet)
229229
{
230230
::fclose(localfile);
231231
seterror("Could not create IComPacket");
232-
return(false);
233-
}
234-
232+
return(false);
233+
}
234+
235235
packet->settag(TAG_FGET);
236236
packet->setid(fileid);
237237
packet->setstring(remotefilename);
@@ -242,7 +242,7 @@ bool FileTransferClient::get_file(std::string remotefilename,std::string localfi
242242
return(false);
243243
}
244244
bool done = false;
245-
245+
246246
while (!done)
247247
{
248248
if (!(recv(packet)))
@@ -266,7 +266,7 @@ bool FileTransferClient::get_file(std::string remotefilename,std::string localfi
266266
seterror("Received unknown packet");
267267
return(false);
268268
}
269-
269+
270270
if ( ::fseek(localfile,static_cast<long>(packet->getparam1()),SEEK_SET) < 0)
271271
{
272272
::fclose(localfile);
@@ -276,65 +276,65 @@ bool FileTransferClient::get_file(std::string remotefilename,std::string localfi
276276
seterror("Fseek error writing local file");
277277
return(false);
278278
}
279-
279+
280280
if ( ::fwrite(packet->getbuffer(),1,static_cast<size_t>(packet->getdatasize()),localfile) != static_cast<size_t>(packet->getdatasize()))
281281
{
282282
::fclose(localfile);
283283
packet->clear();
284284
packet->settag(TAG_FRESET);
285285
send(packet);
286286
seterror("Error writing local file");
287-
return(false);
287+
return(false);
288288
}
289-
289+
290290
if (packet->gettag() == TAG_FEND)
291291
{
292292
done = true;
293293
packet->clear();
294294
continue;
295295
}
296-
296+
297297
int nextoffset = packet->getparam1()+packet->getdatasize();
298298
packet->clear();
299299
packet->settag(TAG_FNEXTDATA);
300300
packet->setid(fileid);
301301
packet->setparam1(nextoffset);
302-
302+
303303
if (!(send(packet)))
304304
{
305305
::fclose(localfile);
306306
seterror("Error sending packet to file transfer service");
307307
return(false);
308308
}
309309
}
310-
310+
311311
::fclose(localfile);
312-
clearerror();
313-
return(true);
312+
clearerror();
313+
return(true);
314314
}
315315

316316

317317
bool FileTransferClient::put_file(std::string localfilename,std::string remotefilename)
318318
{
319-
319+
320320
FILE* localfile;
321321
int fileid = fileidcnt_++;
322-
322+
323323
localfile = ::fopen(localfilename.c_str(),"r");
324324
if (localfile == 0)
325325
{
326326
seterror("Could not open local filename");
327327
return(false);
328328
}
329-
329+
330330
IComPacketHandle packet(new IComPacket);
331331
if (!packet)
332332
{
333333
seterror("Could not create IComPacket");
334334
::fclose(localfile);
335-
return(false);
335+
return(false);
336336
}
337-
337+
338338
packet->settag(TAG_FPUT);
339339
packet->setid(fileid);
340340
packet->setstring(remotefilename);
@@ -369,7 +369,7 @@ bool FileTransferClient::put_file(std::string localfilename,std::string remotefi
369369
seterror("Received unknown packet");
370370
return(false);
371371
}
372-
372+
373373
if ( ::fseek(localfile,static_cast<long>(packet->getparam1()),SEEK_SET) < 0)
374374
{
375375
::fclose(localfile);
@@ -379,17 +379,17 @@ bool FileTransferClient::put_file(std::string localfilename,std::string remotefi
379379
seterror("Fseek error reading local file");
380380
return(false);
381381
}
382-
382+
383383
int seekpos = packet->getparam1();
384384
size_t bytesread = 0;
385-
385+
386386
packet->clear();
387387
packet->newbuffer(buffersize_);
388388
packet->setid(fileid);
389389
packet->setparam1(seekpos);
390-
390+
391391
bytesread = ::fread(packet->getbuffer(),1,buffersize_,localfile);
392-
392+
393393
if (bytesread < buffersize_)
394394
{
395395
packet->setdatasize(bytesread);
@@ -402,21 +402,21 @@ bool FileTransferClient::put_file(std::string localfilename,std::string remotefi
402402
packet->setdatasize(bytesread);
403403
packet->settag(TAG_FDATA);
404404
}
405-
405+
406406
if (!(send(packet)))
407407
{
408408
::fclose(localfile);
409409
seterror("Error sending packet to file transfer service");
410410
return(false);
411411
}
412412
}
413-
413+
414414
::fclose(localfile);
415-
clearerror();
416-
return(true);
415+
clearerror();
416+
return(true);
417417
}
418-
419-
418+
419+
420420

421421
bool FileTransferClient::set_local_dir(std::string dir)
422422
{
@@ -441,7 +441,5 @@ std::string FileTransferClient::remote_file(std::string filename)
441441
{
442442
return(remote_dir_ + filename);
443443
}
444-
445-
} // end namespace
446-
447444

445+
} // end namespace

src/Core/Services/FileTransferClient.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -41,7 +41,7 @@ class SCISHARE FileTransferClient : public ServiceClient
4141
public:
4242
FileTransferClient();
4343
~FileTransferClient();
44-
44+
4545
// open this service. This overloaded open function will deal as well with the first packet send
4646
// by the service, which is an information packet. Containing location and ID of the remote home
4747
// directory
@@ -51,53 +51,53 @@ class SCISHARE FileTransferClient : public ServiceClient
5151
// XXXXXX which will be replace by an uniquely generated string of numbers and letters
5252
bool create_remote_tempdir(std::string pattern,std::string &tempdir);
5353
bool create_local_tempdir(std::string pattern,std::string &tempdir);
54-
54+
5555
// To identify the homedirectories, SCIRun will write a file with a hopefully unique key
5656
// that identifies that directory uniquely. Currently this is only done by the local clock
5757
// and a randomnumber generator. This needs to be replaced with the UUID code, which is
5858
// being included into SCIRun2, but does not have OSX support and still does not function
5959
// all the way. Currently id's are strings that can be replaced with any other object that
60-
// can be written to a string such as UUIDs
60+
// can be written to a string such as UUIDs
6161
bool get_local_homedirid(std::string& homeid);
6262
bool get_remote_homedirid(std::string& homeid);
63-
63+
6464
// Get the path to the local SCIRun temp directory and the remote one.
6565
// Although the directory may point to the same underlying shared drive
6666
// the paths may be different. The function translate_scirun_tempdir translates
6767
// local filenames to remote filenames.
6868
bool get_local_scirun_tempdir(std::string& tempdir);
6969
bool get_remote_scirun_tempdir(std::string& tempdir);
7070
bool translate_scirun_tempdir(std::string& tempdir);
71-
71+
7272
// These are the functions for transfering files forwards and backwards
7373
// between systems. These functions will do the transfer protocol.
7474
// They rely on the full filename (that includes the path)
7575
bool get_file(std::string localfilename,std::string remotefilename);
7676
bool put_file(std::string remotefilename,std::string localfilename);
77-
78-
// The next set of functions are only local and are meant to simplify
77+
78+
// The next set of functions are only local and are meant to simplify
7979
// the task of keeping track what the remote and local directory are called
8080
// set_local_dir sets the local temp directories path. This should preferably
8181
// be an absolute path. The set_remote_dir does the same for the remote directory
8282
// To generate filenames on both systems, local_file() will take the filename and
8383
// put the local_directory in front of it and remote_file() will put the remote
84-
// directory path in front of the filename.
85-
inline bool set_local_dir(std::string dir);
86-
inline bool set_remote_dir(std::string dir);
87-
inline std::string local_file(std::string filename);
88-
inline std::string remote_file(std::string filename);
89-
84+
// directory path in front of the filename.
85+
bool set_local_dir(std::string dir);
86+
bool set_remote_dir(std::string dir);
87+
std::string local_file(std::string filename);
88+
std::string remote_file(std::string filename);
89+
9090
private:
9191
std::string tempdir_;
92-
92+
9393
std::string local_scirun_tempdir_;
9494
std::string remote_scirun_tempdir_;
9595
std::string local_homedirid_;
9696
std::string remote_homedirid_;
97-
97+
9898
std::string remote_dir_;
9999
std::string local_dir_;
100-
100+
101101
boost::shared_ptr<class TempFileManager> tfm_;
102102

103103
int fileidcnt_;
@@ -108,7 +108,7 @@ class SCISHARE FileTransferClient : public ServiceClient
108108
typedef boost::shared_ptr<FileTransferClient> FileTransferClientHandle;
109109

110110

111-
111+
112112
} // end namespace
113-
113+
114114
#endif

0 commit comments

Comments
 (0)