本文整理汇总了C++中PDFDoc::getFopenErrno方法的典型用法代码示例。如果您正苦于以下问题:C++ PDFDoc::getFopenErrno方法的具体用法?C++ PDFDoc::getFopenErrno怎么用?C++ PDFDoc::getFopenErrno使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDFDoc
的用法示例。
在下文中一共展示了PDFDoc::getFopenErrno方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool XojPopplerDocument::load(const char * filename, const char * password, GError ** error) {
XOJ_CHECK_TYPE(XojPopplerDocument);
PDFDoc * newDoc;
GooString * filename_g;
GooString * password_g;
if (!globalParams) {
globalParams = new GlobalParams();
}
if (!filename) {
return false;
}
password_g = NULL;
if (password != NULL) {
if (g_utf8_validate(password, -1, NULL)) {
gchar *password_latin;
password_latin = g_convert(password, -1, "ISO-8859-1", "UTF-8", NULL, NULL, NULL);
password_g = new GooString(password_latin);
g_free(password_latin);
} else {
password_g = new GooString(password);
}
}
#ifdef G_OS_WIN32
wchar_t *filenameW;
int wlen;
wlen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
filenameW = new WCHAR[wlen];
if (!filenameW)
return NULL;
wlen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, wlen);
newDoc = new PDFDoc(filenameW, wlen, password_g, password_g);
delete filenameW;
#else
filename_g = new GooString(filename);
newDoc = new PDFDoc(filename_g, password_g, password_g);
#endif
delete password_g;
if (!newDoc->isOk()) {
int fopen_errno;
switch (newDoc->getErrorCode()) {
case errOpenFile:
// If there was an error opening the file, count it as a G_FILE_ERROR
// and set the GError parameters accordingly. (this assumes that the
// only way to get an errOpenFile error is if newDoc was created using
// a filename and thus fopen was called, which right now is true.
fopen_errno = newDoc->getFopenErrno();
g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(fopen_errno), "%s", g_strerror(fopen_errno));
break;
case errBadCatalog:
g_set_error(error, 0, 0, "Failed to read the document catalog");
break;
case errDamaged:
g_set_error(error, 0, 0, "PDF document is damaged");
break;
case errEncrypted:
g_set_error(error, 0, 0, "Document is encrypted");
break;
default:
g_set_error(error, 0, 0, "Failed to load document");
}
delete newDoc;
return false;
}
if (this->data) {
this->data->unreference();
}
this->data = new _IntPopplerDocument(newDoc);
return true;
}