40 #include <boost/format.hpp>
57 throw BagIOException((format(
"Error writing to file: writing %1% bytes, wrote %2% bytes") % size % result).str());
68 if (nUnused == size) {
70 memcpy(ptr, unused, nUnused);
74 else if (nUnused < size) {
76 memcpy(ptr, unused, nUnused);
82 int result = fread((
char*) ptr + nUnused, 1, size,
getFilePointer());
83 if ((
size_t) result != size)
84 throw BagIOException((format(
"Error reading from file + unused: wanted %1% bytes, read %2% bytes") % size % result).str());
92 memcpy(ptr, unused, size);
101 if ((
size_t) result != size)
102 throw BagIOException((format(
"Error reading from file: wanted %1% bytes, read %2% bytes") % size % result).str());
108 if (dest_len < source_len)
111 memcpy(dest, source, source_len);