#include "Utility.h" #include unsigned long sa::ws::Utility::getFileSize(const std::string &filepath) throw(boost::filesystem::filesystem_error) { boost::filesystem::path p(filepath, boost::filesystem::native); return boost::filesystem::file_size(p); } sa::ws::SharedCharArray_t sa::ws::Utility::loadFile(const std::string &filename) throw(boost::filesystem::filesystem_error) { SharedCharArray_t buf; unsigned long size = getFileSize(filename); if (!size) return buf; std::ifstream is(filename.c_str(), std::ios::in | std::ios::binary); if (!is) return buf; char *buffer(NULL); buffer = new char[size]; if (!buffer) { is.close(); return buf; } is.read(buffer, size); if (is.fail()) { delete [] buffer; return buf; } is.close(); buf.reset(buffer); return buf; }