#include "KM_util.h"
#include "KM_fileio.h"
#include "AS_DCP.h"
+#include <openjpeg.h>
#include <xmlsec/xmldsig.h>
#include <xmlsec/dl.h>
#include <xmlsec/app.h>
throw MiscError ("Unexpectedly long file");
}
- char* c = new char[len + 1];
-
FILE* f = fopen_boost (p, "r");
if (!f) {
- return "";
+ throw FileError ("could not open file", p, errno);
}
- fread (c, 1, len, f);
+ char* c = new char[len];
+ /* This may read less than `len' if we are on Windows and we have CRLF in the file */
+ int const N = fread (c, 1, len, f);
fclose (f);
- c[len] = '\0';
- string s (c);
+ string s (c, N);
delete[] c;
return s;