"Fossies" - the Fresh Open Source Software Archive

Member "bonnie++-1.04/bon_io.h" (3 Jul 2009, 1363 Bytes) of package /linux/privat/bonnie++_1.04.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "bon_io.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef BON_FILE
    2 #define BON_FILE
    3 
    4 #include "bonnie.h"
    5 class Semaphore;
    6 class BonTimer;
    7 
    8 class CFileOp
    9 {
   10 public:
   11   CFileOp(BonTimer &timer, int file_size, int chunk_bits, bool use_sync = false
   12 #ifdef O_DIRECT
   13         , bool use_direct_io = false
   14 #endif
   15          );
   16   int open(CPCCHAR base_name, bool create, bool use_fopen = false);
   17   ~CFileOp();
   18   int write_block_putc();
   19   int write_block(PVOID buf);
   20   int read_block_getc(char *buf);
   21   int read_block(PVOID buf);
   22   int seek(int offset, int whence);
   23   int doseek(long where, bool update);
   24   int seek_test(bool quiet, Semaphore &s);
   25   void close();
   26   // reopen a file, bools for whether the file should be unlink()'d and
   27   // creat()'d and for whether fopen should be used
   28   int reopen(bool create, bool use_fopen = false);
   29   BonTimer &getTimer() { return m_timer; }
   30   int chunks() const { return m_total_chunks; }
   31 private:
   32   int m_open(CPCCHAR base_name, int ind, bool create);
   33 
   34   BonTimer &m_timer;
   35   FILE **m_stream;
   36   FILE_TYPE *m_fd;
   37   bool m_isopen;
   38   char *m_name;
   39   bool m_sync;
   40 #ifdef O_DIRECT
   41   bool m_use_direct_io;
   42 #endif
   43   const int m_chunk_bits, m_chunk_size;
   44   int m_chunks_per_file, m_total_chunks;
   45   int m_last_file_chunks;
   46   int m_cur_pos;
   47   int m_file_ind;
   48   int m_file_size;
   49   int m_num_files;
   50   CFileOp(const CFileOp &f);
   51   CFileOp & operator =(const CFileOp &f);
   52   char *m_buf;
   53 };
   54 
   55 
   56 #endif