154 ddjvu_document_t *doc;
156 gboolean missing_files =
FALSE;
157 gboolean check_for_missing_files =
FALSE;
158 GError *djvu_error = NULL;
164 filename = g_filename_from_uri (uri, NULL, error);
169 doc = ddjvu_document_create_by_filename_utf8 (djvu_document->
d_context, filename,
TRUE);
171 doc = ddjvu_document_create_by_filename (djvu_document->
d_context, filename,
TRUE);
176 g_set_error_literal (error,
179 _(
"DjVu document has incorrect format"));
184 ddjvu_document_release (djvu_document->
d_document);
190 g_set_error_literal (error,
193 djvu_error->message);
194 g_error_free (djvu_error);
196 ddjvu_document_release (djvu_document->
d_document);
202 if (ddjvu_document_decoding_error (djvu_document->
d_document))
206 g_set_error_literal (error,
209 djvu_error->message);
210 g_error_free (djvu_error);
212 ddjvu_document_release (djvu_document->
d_document);
218 g_free (djvu_document->
uri);
219 djvu_document->
uri = g_strdup (uri);
223 if (djvu_document->
n_pages > 0) {
225 djvu_document->
file_ids = g_hash_table_new (g_str_hash, g_str_equal);
227 if (ddjvu_document_get_type (djvu_document->
d_document) == DDJVU_DOCTYPE_INDIRECT)
228 check_for_missing_files =
TRUE;
230 base = g_path_get_dirname (filename);
232 n_files = ddjvu_document_get_filenum (djvu_document->
d_document);
233 for (i = 0; i < n_files; i++) {
234 ddjvu_fileinfo_t fileinfo;
237 ddjvu_document_get_fileinfo (djvu_document->
d_document,
240 if (fileinfo.type !=
'P')
243 if (fileinfo.pageno >= 0 && fileinfo.pageno < djvu_document->
n_pages) {
247 g_hash_table_insert (djvu_document->
file_ids,
249 GINT_TO_POINTER(fileinfo.pageno));
251 if (check_for_missing_files && !missing_files) {
252 file = g_build_filename (base, fileinfo.id, NULL);
253 if (!g_file_test (file, G_FILE_TEST_EXISTS)) {
254 missing_files =
TRUE;
263 g_set_error_literal (error,
266 _(
"The document is composed of several files. "
267 "One or more of these files cannot be accessed."));