DumpFileControl.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_DumpFileControl_h_
00003 #define INCLUDED_DumpFileControl_h_
00004
00005 #include "FileBrowserControl.h"
00006 #include <fstream>
00007
00008
00009 class DumpFileControl : public FileBrowserControl {
00010 public:
00011
00012 DumpFileControl(const std::string& n,const std::string& r)
00013 : FileBrowserControl(n,"Dumps a user specified file to the console",r)
00014 {}
00015
00016 virtual ~DumpFileControl() {}
00017
00018 protected:
00019
00020 virtual ControlBase* selectedFile(const std::string& f) {
00021 const unsigned int BUFSIZE=128;
00022 doRewrite=false;
00023 std::ifstream in(f.c_str());
00024 while(in) {
00025 byte* buf=sout->getWriteBuffer(BUFSIZE);
00026 if(buf==NULL) {
00027 serr->printf("DumpFileControl - write failed\n");
00028 return this;
00029 }
00030 in.read(reinterpret_cast<char*>(buf),BUFSIZE);
00031 sout->write(in.gcount());
00032 }
00033 sout->printf("\n");
00034 return this;
00035 }
00036 };
00037
00038
00039
00040
00041
00042
00043 #endif