COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/include/coopy/FileIO.h
Go to the documentation of this file.
00001 #ifndef COOPY_FILEIO
00002 #define COOPY_FILEIO
00003 
00004 #include <stdio.h>
00005 
00006 #include <coopy/Property.h>
00007 
00008 namespace coopy {
00009   namespace store {
00010     class FileIO;
00011   }
00012 }
00013 
00014 class coopy::store::FileIO {
00015 private:
00016   FILE *fp;
00017   bool need_close;
00018   size_t pending_length;
00019   bool has_length;
00020 public:
00021   FileIO() {
00022     fp = NULL;
00023     need_close = false;
00024     pending_length = 0;
00025     has_length = false;
00026   }
00027 
00028   virtual ~FileIO() {
00029     close();
00030   }
00031 
00032   bool open(const char *src, const Property& config);
00033 
00034   bool openForWrite(const char *dest, const Property& config);
00035 
00036   bool close();
00037 
00038   size_t fread(void *ptr, size_t size, size_t nmemb);
00039 
00040   bool isPiped() {
00041     return fp==stdin;
00042   }
00043 
00044   bool isValid() {
00045     return fp!=NULL;
00046   }
00047 
00048   bool openAndWrite(const std::string& txt, const Property& config);
00049 
00050   FILE *get() {
00051     return fp;
00052   }
00053 };
00054 
00055 #endif
00056 
00057 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines