/** @file $Id$ $Date$ $Author$ @copy © Marc Wäckerlin @license LGPL, see file COPYING $Log$ Revision 1.1 2005/01/07 00:31:38 marc initial version 1 2 3 4 5 6 7 8 5678901234567890123456789012345678901234567890123456789012345678901234567890 */ #ifndef __MRW_FILE_HPP__ #define __MRW_FILE_HPP__ #include #include #include namespace mrw { class File { public: static void copy(std::string from, std::string to) throw (std::exception) { std::ifstream is(from.c_str()); if (!is) throw mrw::invalid_argument("Cannot read file: '"+from+"'"); is.seekg(0, std::ios::end); int size(is.tellg()); std::string contents(size, 0); // make buffer long enough to store all is.seekg(0, std::ios::beg); is.read(contents.begin().operator->(), size); // hack to get the buffer if (!is.good() && is.eof()) throw mrw::invalid_argument("Cannot read file: '"+from+"'"); std::ofstream os(to.c_str()); os<