LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
FileIo.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <sys/fcntl.h>
36 #include <aio.h>
37 #include <errno.h>
38 
39 #include <zlib.h>
40 #if ZLIB_VERNUM < 0x123
41 # warning Older version of zlib detected, upgrading to version 1.2.3 or later is recommended
42 #endif
43 
44 #include <cstring>
45 #include <algorithm>
46 
47 #include "boost/bind.hpp"
48 #include "boost/format.hpp"
49 
50 #include "lsst/pex/exceptions.h"
51 
52 #include "lsst/ap/Common.h"
53 #include "lsst/ap/ScopeGuard.h"
54 #include "lsst/ap/Time.h"
55 #include "lsst/ap/io/FileIo.h"
56 
57 namespace ex = lsst::pex::exceptions;
58 
59 namespace lsst { namespace ap { namespace io { namespace {
60 
61 int openFile(
62  std::string const & fileName,
63  int const oflag,
64  ::mode_t const mode = 0
65 ) {
66  int fd = ::open(fileName.c_str(), oflag, mode);
67  if (fd == -1) {
68  if (errno != ENOENT || (oflag & O_WRONLY) != 0) {
69  throw LSST_EXCEPT(ex::IoError,
70  (boost::format("open() failed on file %1%, flags: %2%, errno: %3%") %
71  fileName % oflag % errno).str());
72  }
73  // file didn't exist (ok when opening for reading)
74  }
75  return fd;
76 }
77 
78 }}}} // end of anonymous namespace
79 
80 
81 // -- SequentialIoBase ----------------
82 
84 
86 
87 
88 // -- SequentialFileReader ----------------
89 
91  std::string const & fileName
92 ) :
93  _fd(-1)
94 {
95  int const fd = openFile(fileName, false, O_RDONLY);
96  if (fd == -1) {
97  _state = FINISHED;
98  return;
99  }
100  _fd = fd;
101 }
102 
103 
105 
106 
108  if (_fd != -1) {
109  ::close(_fd);
110  _fd = -1;
111  }
112 }
113 
114 
116  unsigned char * const buf,
117  std::size_t const len
118 ) {
119  if (len == 0) {
120  return 0;
121  }
122  if (buf == 0) {
123  throw LSST_EXCEPT(ex::InvalidParameterError,
124  "null pointer to read destination");
125  }
126  if (_state == FAILED) {
127  throw LSST_EXCEPT(ex::IoError,
128  "read() called on a failed SequentialFileReader");
129  } else if (_state == FINISHED) {
130  return 0;
131  }
132 
133  ::ssize_t n = ::read(_fd, buf, len);
134  if (n < 0) {
135  cleanup(FAILED);
136  throw LSST_EXCEPT(ex::IoError,
137  (boost::format("read() failed, errno: %1%") % errno).str());
138  } else if (n == 0) {
139  cleanup(FINISHED);
140  }
141  return static_cast<std::size_t>(n);
142 }
143 
144 
145 // -- SequentialFileWriter ----------------
146 
148  std::string const & fileName,
149  bool const overwrite
150 ) :
151  _fd(-1)
152 {
153  int const fd = openFile(
154  fileName,
155  O_WRONLY | O_CREAT | O_APPEND | (overwrite ? O_TRUNC : O_EXCL),
156  S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
157  );
158  assert(fd != -1);
159  _fd = fd;
160 }
161 
162 
164 
165 
167  if (_fd != -1) {
168  ::close(_fd);
169  }
170 }
171 
172 
174  unsigned char const * const buf,
175  std::size_t const len
176 ) {
177  if (len == 0) {
178  return;
179  }
180  if (buf == 0) {
181  throw LSST_EXCEPT(ex::InvalidParameterError,
182  "null pointer to bytes to write");
183  }
184  if (_state != IN_PROGRESS) {
185  throw LSST_EXCEPT(ex::IoError,
186  "write() called on a finished or failed SequentialFileWriter");
187  }
188 
189  unsigned char const * dst = buf;
190  std::size_t nb = len;
191  do {
192  ::ssize_t n = ::write(_fd, dst, nb);
193  if (n < 0) {
194  cleanup(FAILED);
195  throw LSST_EXCEPT(ex::IoError,
196  (boost::format("write() failed, errno: %1%") % errno).str());
197  }
198  dst += n;
199  nb -= n;
200  } while (nb > 0);
201 }
202 
203 
205  if (_state != IN_PROGRESS) {
206  throw LSST_EXCEPT(ex::IoError,
207  "finish() called on a finished or failed SequentialFileWriter");
208  }
209 
210  // Flush userland and kernel buffers
211  while (fsync(_fd) != 0) {
212  if (errno != EINTR) {
213  cleanup(FAILED);
214  throw LSST_EXCEPT(ex::IoError,
215  (boost::format("fsync() failed, errno: %1%") % errno).str());
216  }
217  errno = 0;
218  }
219  cleanup(FINISHED);
220 }
221 
222 
223 // -- CompressedFileReader ----------------
224 
226  std::string const & fileName,
227  std::size_t const blockSize
228 ) :
229  _memory(0),
230  _buffers(0),
231  _blockSize(blockSize),
232  _fileSize(0),
233  _remaining(0),
234  _fd(-1)
235 {
236  if (blockSize < 1024 || blockSize > 16777216 || (blockSize & (blockSize - 1)) != 0) {
237  throw LSST_EXCEPT(ex::InvalidParameterError,
238  "I/O block size must be a power of 2 between 2^10 and 2^24 bytes");
239  }
240 
241  std::memset(&_stream, 0, sizeof(::z_stream));
242  std::memset(&_request, 0, sizeof(::aiocb));
243  _request.aio_fildes = -1;
244 
245  // allocate IO buffers, store pointer to 8k aligned location inside buffer
246  boost::scoped_array<unsigned char> mem(new unsigned char[2*blockSize + 8192]);
247  std::size_t buf = reinterpret_cast<std::size_t>(mem.get());
248  _buffers = reinterpret_cast<unsigned char *>((buf + 8191) & ~static_cast<std::size_t>(8191));
249 
250  // open file
251  int const fd = openFile(fileName, O_RDONLY);
252  if (fd == -1) {
253  _state = FINISHED;
254  return;
255  }
256  ScopeGuard fdGuard(boost::bind(::close, fd));
257 
258  // determine file size
259  struct stat sb;
260  if (::fstat(fd, &sb) != 0) {
261  throw LSST_EXCEPT(ex::IoError,
262  (boost::format("fstat() failed on file %1%, errno: %2%") % fileName % errno).str());
263  }
264  _fileSize = static_cast<std::size_t>(sb.st_size);
265  if (_fileSize == 0) {
266  _state = FINISHED;
267  return;
268  }
270 
271  // setup zlib (specify auto-detection of zlib/gzip header)
272  if (inflateInit2(&_stream, MAX_WBITS + 32) != Z_OK) {
273  throw LSST_EXCEPT(ex::RuntimeError,
274  "[zlib] inflateInit2() failed to initialize decompression stream");
275  }
276  ScopeGuard zlibGuard(boost::bind(::inflateEnd, &_stream));
277 
278  // issue first async read
279  std::size_t const nb = std::min(blockSize, _fileSize);
280  _request.aio_fildes = fd;
281  _request.aio_buf = _buffers;
282  _request.aio_nbytes = nb;
283  if (::aio_read(&_request) != 0) {
284  throw LSST_EXCEPT(ex::IoError,
285  (boost::format("aio_read() failed to enqueue IO request for file %1%, errno: %2%") %
286  fileName % errno).str());
287  }
288  _fd = fd;
289  using std::swap;
290  swap(_memory, mem);
291  zlibGuard.dismiss();
292  fdGuard.dismiss();
293 }
294 
295 
297  cleanup();
298 }
299 
300 
302  if (_fd != -1) {
303  if (_state == IN_PROGRESS) {
304  ::aio_cancel(_fd, 0);
305  }
306  ::close(_fd);
307  ::inflateEnd(&_stream);
308  _fd = -1;
309  }
310 }
311 
312 
314  unsigned char * const buf,
315  std::size_t const len
316 ) {
317  if (len == 0) {
318  return 0;
319  }
320  if (buf == 0) {
321  throw LSST_EXCEPT(ex::InvalidParameterError, "null pointer to read destination");
322  }
323  if (_state == FAILED) {
324  throw LSST_EXCEPT(ex::IoError, "read() called on a failed CompressedFileReader");
325  } else if (_state == FINISHED) {
326  return 0;
327  }
328 
329  // if the current block has not been fully transferred to the user,
330  // decompress as much as possible of what remains
331  _stream.next_out = buf;
332  _stream.avail_out = len;
333  if (_stream.avail_in > 0) {
334  int const zret = ::inflate(&_stream, Z_SYNC_FLUSH);
335  if (zret == Z_STREAM_END) {
336  if (_remaining != 0) {
337  cleanup(FAILED);
338  throw LSST_EXCEPT(ex::RuntimeError,
339  "[zlib] inflate(): unexpected end of stream");
340  }
341  if (_stream.avail_in != 0) {
342  cleanup(FAILED);
343  throw LSST_EXCEPT(ex::RuntimeError,
344  "[zlib] inflate() failed to consume input");
345  }
346  cleanup(FINISHED);
347  return len - _stream.avail_out;
348  } else if (zret == Z_OK) {
349  if (_stream.avail_out == 0) {
350  return len;
351  } else if (_remaining == 0) {
352  cleanup(FAILED);
353  throw LSST_EXCEPT(ex::RuntimeError,
354  "[zlib] inflate(): expected end of stream");
355  } else if (_stream.avail_in != 0) {
356  cleanup(FAILED);
357  throw LSST_EXCEPT(ex::RuntimeError,
358  "[zlib] inflate() failed to consume input");
359  }
360  // user has space for even more data
361  } else {
362  cleanup(FAILED);
363  throw LSST_EXCEPT(ex::RuntimeError,
364  (boost::format("[zlib] inflate() failed, return code: %1%") % zret).str());
365  }
366  }
367 
368  // Current block is consumed, so block on outstanding request
369  while (::aio_error(&_request) == EINPROGRESS) {
370  TimeSpec timeout;
371  ::aiocb * const list = &_request;
372  timeout.tv_sec = 10; // wait up to 10 seconds
373  if (::aio_suspend(&list, 1, &timeout) != 0) {
374  if (errno != EINTR) {
375  if (errno == EAGAIN) {
376  cleanup(FAILED);
377  throw LSST_EXCEPT(ex::TimeoutError, "aio_read() timed out");
378  } else {
379  cleanup(FAILED);
380  throw LSST_EXCEPT(ex::IoError,
381  (boost::format("aio_suspend() failed, errno: %1%") % errno).str());
382  }
383  }
384  errno = 0;
385  }
386  }
387 
388  // check status of the read that just completed
389  int const nb = ::aio_return(&_request);
390  if (nb < 0) {
391  cleanup(FAILED);
392  throw LSST_EXCEPT(ex::IoError,
393  (boost::format("aio_read() failed, errno: %1%") % ::aio_error(&_request)).str());
394  } else if (nb == 0) {
395  cleanup(FAILED);
396  throw LSST_EXCEPT(ex::IoError, "aio_read(): unexpected end of file reached");
397  }
398 
399  unsigned char * ready = static_cast<unsigned char *>(const_cast<void *>(_request.aio_buf));
400  _remaining -= static_cast<std::size_t>(nb);
401  if (_remaining > 0) {
402  // issue prefetch for the next block
403  _request.aio_buf = (ready == _buffers) ? ready + _blockSize : _buffers;
404  _request.aio_offset = _fileSize - _remaining;
405  _request.aio_nbytes = std::min(_blockSize, _remaining);
406  if (::aio_read(&_request) != 0) {
407  cleanup(FAILED);
408  throw LSST_EXCEPT(ex::IoError,
409  (boost::format("aio_read() failed to enqueue IO request, errno: %1%") % errno).str());
410  }
411  }
412 
413  // Decompress into user-supplied buffer
414  _stream.next_in = ready;
415  _stream.avail_in = nb;
416  int const zret = ::inflate(&_stream, Z_SYNC_FLUSH);
417  if (zret == Z_STREAM_END) {
418  if (_remaining != 0) {
419  cleanup(FAILED);
420  throw LSST_EXCEPT(ex::RuntimeError,
421  "[zlib] inflate(): unexpected end of stream");
422  }
423  if (_stream.avail_in != 0) {
424  cleanup(FAILED);
425  throw LSST_EXCEPT(ex::RuntimeError,
426  "[zlib] inflate() failed to consume input");
427  }
428  cleanup(FINISHED);
429  } else if (zret != Z_OK) {
430  cleanup(FAILED);
431  throw LSST_EXCEPT(ex::RuntimeError,
432  (boost::format("[zlib] inflate() failed, return code: %1%") % zret).str());
433  } else if (_stream.avail_out != 0) {
434  if (_remaining == 0) {
435  cleanup(FAILED);
436  throw LSST_EXCEPT(ex::RuntimeError,
437  "[zlib] inflate(): expected end of stream");
438  } else if (_stream.avail_in != 0) {
439  cleanup(FAILED);
440  throw LSST_EXCEPT(ex::RuntimeError,
441  "[zlib] inflate() failed to consume input");
442  }
443  }
444  return len - _stream.avail_out;
445 }
446 
447 
448 // -- CompressedFileWriter ----------------
449 
451  std::string const & fileName,
452  bool const overwrite,
453  std::size_t const blockSize
454 ) :
455  _memory(0),
456  _buffers(0),
457  _blockSize(blockSize),
458  _fd(-1),
459  _started(false)
460 {
461  if (blockSize < 1024 || blockSize > 16777216) {
462  throw LSST_EXCEPT(ex::InvalidParameterError,
463  "I/O block size must be a power of 2 between 2^10 and 2^24 bytes");
464  }
465 
466  std::memset(&_stream, 0, sizeof(::z_stream));
467  std::memset(&_request, 0, sizeof(::aiocb));
468  _request.aio_fildes = -1;
469 
470  // allocate IO buffers, store pointer to 8k aligned location inside buffer
471  boost::scoped_array<unsigned char> mem(new unsigned char[2*blockSize + 8192]);
472  std::size_t buf = reinterpret_cast<std::size_t>(mem.get());
473  _buffers = reinterpret_cast<unsigned char *>((buf + 8191) & ~static_cast<std::size_t>(8191));
474 
475  // open file
476  int const fd = openFile(
477  fileName,
478  O_WRONLY | O_CREAT | O_APPEND | (overwrite ? O_TRUNC : O_EXCL),
479  S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
480  );
481  assert(fd != -1);
482  ScopeGuard fdGuard(boost::bind(::close, fd));
483 
484  // setup zlib (15 window bits, add 16 to indicate a gzip compatible header is desired)
485  if (deflateInit2(&_stream, 1, Z_DEFLATED, MAX_WBITS + 16, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK) {
486  throw LSST_EXCEPT(ex::RuntimeError,
487  "[zlib] deflateInit2() failed to initialize compression stream");
488  }
489 
490  _request.aio_fildes = fd;
491  _request.aio_buf = _buffers;
492  _request.aio_nbytes = blockSize;
493  _fd = fd;
494  using std::swap;
495  swap(_memory, mem);
496  fdGuard.dismiss();
497 }
498 
499 
501 
502 
504  if (_fd != -1) {
505  if (_started) {
506  ::aio_cancel(_fd, 0);
507  }
508  ::close(_fd);
509  ::deflateEnd(&_stream);
510  _fd = -1;
511  }
512 }
513 
514 
516  unsigned char const * const buf,
517  std::size_t const len
518 ) {
519  if (len == 0) {
520  return;
521  }
522  if (buf == 0) {
523  throw LSST_EXCEPT(ex::InvalidParameterError,
524  "null pointer to read destination");
525  }
526  if (_state != IN_PROGRESS) {
527  throw LSST_EXCEPT(ex::IoError,
528  "write() called on a finished or failed CompressedFileWriter");
529  }
530 
531  _stream.next_in = const_cast<Bytef *>(buf);
532  _stream.avail_in = len;
533  if (_stream.avail_out == 0) {
534  unsigned char * buf = static_cast<unsigned char *>(const_cast<void *>(_request.aio_buf));
535  _stream.next_out = (buf == _buffers) ? buf + _blockSize : _buffers;
536  _stream.avail_out = _blockSize;
537  }
538 
539  // deflate/write until the buffer passed in by the user has been consumed
540  do {
541 
542  int const zret = ::deflate(&_stream, Z_NO_FLUSH);
543  if (zret != Z_OK) {
544  cleanup(FAILED);
545  throw LSST_EXCEPT(ex::RuntimeError,
546  (boost::format("[zlib] deflate() failed, return code: %1%") % zret).str());
547  }
548  if (_stream.avail_out != 0) {
549  if (_stream.avail_in != 0) {
550  cleanup(FAILED);
551  throw LSST_EXCEPT(ex::RuntimeError,
552  "[zlib] deflate() failed to consume input");
553  }
554  break;
555  }
556 
557  if (_stream.avail_out == 0) {
558  if (_started) {
559  // wait for pending write to finish
560  while (::aio_error(&_request) == EINPROGRESS) {
561  TimeSpec timeout;
562  ::aiocb * const list = &_request;
563  timeout.tv_sec = 10; // wait up to 10 seconds
564  if (::aio_suspend(&list, 1, &timeout) != 0) {
565  if (errno != EINTR) {
566  if (errno == EAGAIN) {
567  cleanup(FAILED);
568  throw LSST_EXCEPT(ex::TimeoutError, "aio_write() timed out");
569  } else {
570  cleanup(FAILED);
571  throw LSST_EXCEPT(ex::IoError,
572  (boost::format("aio_suspend() failed, errno: %1%") % errno).str());
573  }
574  }
575  errno = 0;
576  }
577  }
578  // check status of the write that just completed
579  if (::aio_return(&_request) != static_cast<int>(_blockSize)) {
580  cleanup(FAILED);
581  throw LSST_EXCEPT(ex::IoError,
582  (boost::format("aio_write() failed, errno: %1%") %
583  ::aio_error(&_request)).str());
584  }
585  }
586  unsigned char * buf = static_cast<unsigned char *>(const_cast<void *>(_request.aio_buf));
587  _request.aio_buf = _stream.next_out - _blockSize;
588  _stream.next_out = buf;
589  _stream.avail_out = _blockSize;
590  // issue asynchronous write
591  if (aio_write(&_request) != 0) {
592  cleanup(FAILED);
593  throw LSST_EXCEPT(ex::IoError,
594  (boost::format("aio_write() failed to enqueue IO request") % errno).str());
595  }
596  _started = true;
597  } else if (_stream.avail_in != 0) {
598  throw LSST_EXCEPT(ex::RuntimeError,
599  "[zlib] deflate() failed to consume input");
600  }
601 
602  } while(_stream.avail_in != 0);
603 }
604 
605 
607 
608  if (_state != IN_PROGRESS) {
609  throw LSST_EXCEPT(ex::IoError,
610  "finish() called on a finished or failed CompressedFileWriter");
611  }
612 
613  if (_stream.avail_out == 0) {
614  unsigned char * buf = static_cast<unsigned char *>(const_cast<void *>(_request.aio_buf));
615  _stream.next_out = (buf == _buffers) ? buf + _blockSize : _buffers;
616  _stream.avail_out = _blockSize;
617  }
618 
619  while (true) {
620 
621  int const zret = ::deflate(&_stream, Z_FINISH);
622  if (zret != Z_STREAM_END && zret != Z_OK) {
623  cleanup(FAILED);
624  throw LSST_EXCEPT(ex::RuntimeError,
625  (boost::format("[zlib] deflate() failed, return code: %1%") % zret).str());
626  }
627  if (_started) {
628  while (::aio_error(&_request) == EINPROGRESS) {
629  TimeSpec timeout;
630  ::aiocb * const list = &_request;
631  timeout.tv_sec = 10; // wait up to 10 seconds
632  if (::aio_suspend(&list, 1, &timeout) != 0) {
633  if (errno != EINTR) {
634  if (errno == EAGAIN) {
635  cleanup(FAILED);
636  throw LSST_EXCEPT(ex::TimeoutError, "aio_write() timed out");
637  } else {
638  cleanup(FAILED);
639  throw LSST_EXCEPT(ex::IoError,
640  (boost::format("aio_suspend() failed, errno: %1%") % errno).str());
641  }
642  }
643  errno = 0;
644  }
645  }
646  // check status of the write that just completed
647  if (::aio_return(&_request) != static_cast<int>(_blockSize)) {
648  cleanup(FAILED);
649  throw LSST_EXCEPT(ex::IoError,
650  (boost::format("aio_write() failed, errno: %1%") %
651  ::aio_error(&_request)).str());
652  }
653  }
654  if (zret == Z_STREAM_END) {
655  break;
656  }
657 
658  unsigned char * buf = static_cast<unsigned char *>(const_cast<void *>(_request.aio_buf));
659  _stream.next_out = buf;
660  _stream.avail_out = _blockSize;
661  // issue asynchronous write of the deflated data
662  _request.aio_buf = (buf == _buffers) ? buf + _blockSize : _buffers;
663  if (::aio_write(&_request) != 0) {
664  cleanup(FAILED);
665  throw LSST_EXCEPT(ex::IoError,
666  (boost::format("aio_write() failed to enqueue IO request") % errno).str());
667  }
668  _started = true;
669 
670  }
671 
672  // no outstanding IO remains, perform final (blocking) write
673  std::size_t bytesRemaining = _blockSize - _stream.avail_out;
674  unsigned char * buf = _stream.next_out - bytesRemaining;
675  while (bytesRemaining > 0) {
676  ::ssize_t nb = ::write(_fd, buf, bytesRemaining);
677  if (nb < 0) {
678  cleanup(FAILED);
679  throw LSST_EXCEPT(ex::IoError,
680  (boost::format("write() failed, errno: %1%") % errno).str());
681  }
682  bytesRemaining -= static_cast<std::size_t>(nb);
683  buf += nb;
684  }
685  // flush both userland and kernel buffers
686  while (::fsync(_fd) != 0) {
687  if (errno != EINTR) {
688  cleanup(FAILED);
689  throw LSST_EXCEPT(ex::IoError,
690  (boost::format("fsync() failed, errno: %1%") % errno).str());
691  }
692  errno = 0;
693  }
694  cleanup(FINISHED);
695 }
696 
::z_stream _stream
zlib state
Definition: FileIo.h:225
Low-level sequential file IO classes.
void swap(Ellipse< DataT > &a, Ellipse< DataT > &b)
Definition: EllipseTypes.h:90
boost::scoped_array< unsigned char > _memory
Definition: FileIo.h:223
Wraps the C library timespec struct.
Definition: Time.h:48
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
virtual ~SequentialIoBase()=0
Definition: FileIo.cc:85
int _fd
file descriptor
Definition: FileIo.h:188
virtual void write(unsigned char const *const buf, std::size_t const size)
Writes len bytes from buf to the underlying storage device.
Definition: FileIo.cc:515
CompressedFileReader(std::string const &fileName, std::size_t const blockSize=262144)
Definition: FileIo.cc:225
Utility class for automatically invoking a function when leaving a scope.
Definition: ScopeGuard.h:51
virtual void finish()
Moves modified data to the underlying storage device and marks the SequentialWriter as finished...
Definition: FileIo.cc:606
virtual std::size_t read(unsigned char *const buf, std::size_t const size)
Definition: FileIo.cc:115
double min
Definition: attributes.cc:216
::aiocb _request
Outstanding IO request.
Definition: FileIo.h:184
::aiocb _request
Outstanding IO request.
Definition: FileIo.h:226
boost::scoped_array< unsigned char > _memory
Definition: FileIo.h:181
Convenience wrapper for the C library timespec struct and a simple profiling class.
std::size_t _fileSize
Size of the file being read.
Definition: FileIo.h:186
Master header file for the association pipeline.
virtual std::size_t read(unsigned char *const buf, std::size_t const size)
Definition: FileIo.cc:313
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual void finish()
Moves modified data to the underlying storage device and marks the SequentialWriter as finished...
Definition: FileIo.cc:204
virtual void write(unsigned char const *const buf, std::size_t const len)
Writes len bytes from buf to the underlying storage device.
Definition: FileIo.cc:173
unsigned char * _buffers
aligned input buffers
Definition: FileIo.h:182
::z_stream _stream
zlib state
Definition: FileIo.h:183
CompressedFileWriter(std::string const &fileName, bool const overwrite=false, std::size_t const blockSize=262144)
Definition: FileIo.cc:450
std::size_t _remaining
Bytes that haven&#39;t yet been read.
Definition: FileIo.h:187
SequentialFileWriter(std::string const &fileName, bool const overwrite=false)
Definition: FileIo.cc:147
Include files required for standard LSST Exception handling.
unsigned char * _buffers
aligned output buffers
Definition: FileIo.h:224
SequentialFileReader(std::string const &fileName)
Definition: FileIo.cc:90
Utility class for automatically invoking a function when leaving a scope.