97
102
totem_resolve_symlink (const char *device, GError **error)
103
108
f = g_strdup (device);
104
109
while (g_file_test (f, G_FILE_TEST_IS_SYMLINK)) {
105
link = g_file_read_link (f, error);
110
_link = g_file_read_link (f, error);
111
116
dir = g_path_get_dirname (f);
112
f1 = g_build_filename (dir, link, NULL);
117
f1 = g_build_filename (dir, _link, NULL);
265
cd_cache_uri_to_archive (const char *uri)
267
char *escaped, *escaped2, *retval;
269
escaped = g_uri_escape_string (uri, NULL, FALSE);
270
escaped2 = g_uri_escape_string (escaped, NULL, FALSE);
272
retval = g_strdup_printf ("archive://%s/", escaped2);
279
cd_cache_mount_archive_callback (GObject *source_object,
281
CdCacheCallbackData *data)
283
data->result = g_file_mount_enclosing_volume_finish (G_FILE (source_object), res, &data->error);
270
cd_cache_check_archive (CdCache *cache,
271
const char *filename,
274
#ifndef HAVE_LIBARCHIVE
275
g_set_error (error, TOTEM_PL_PARSER_ERROR, TOTEM_PL_PARSER_ERROR_MOUNT_FAILED,
276
_("Failed to mount %s."), filename);
280
struct archive_entry *entry;
281
const char * content_types[] = { NULL, NULL };
284
a = archive_read_new();
285
archive_read_support_compression_all(a);
286
archive_read_support_format_all(a);
287
r = archive_read_open_filename(a, filename, 10240);
288
if (r != ARCHIVE_OK) {
289
g_set_error (error, TOTEM_PL_PARSER_ERROR, TOTEM_PL_PARSER_ERROR_MOUNT_FAILED,
290
_("Failed to mount %s."), filename);
293
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
296
name = archive_entry_pathname (entry);
297
if (g_ascii_strcasecmp (name, "VIDEO_TS/VIDEO_TS.IFO") == 0) {
298
content_types[0] = "x-content/video-dvd";
299
cache->content_types = g_strdupv ((gchar**) content_types);
301
} else if (g_ascii_strcasecmp (name, "mpegav/AVSEQ01.DAT") == 0) {
302
content_types[0] = "x-content/video-vcd";
303
cache->content_types = g_strdupv ((gchar**) content_types);
305
} else if (g_ascii_strcasecmp (name, "MPEG2/AVSEQ01.MPG") == 0) {
306
content_types[0] = "x-content/video-svcd";
307
cache->content_types = g_strdupv ((gchar**) content_types);
310
archive_read_data_skip(a);
312
r = archive_read_finish(a);
313
if (r != ARCHIVE_OK) {
314
g_set_error (error, TOTEM_PL_PARSER_ERROR, TOTEM_PL_PARSER_ERROR_MOUNT_FAILED,
315
_("Failed to mount %s."), filename);
322
357
} else if (g_file_test (local, G_FILE_TEST_IS_REGULAR)) {
325
char *uri, *archive_path;
327
358
cache = g_new0 (CdCache, 1);
328
359
cache->is_iso = TRUE;
329
360
cache->is_media = FALSE;
331
uri = g_file_get_uri (file);
332
362
g_object_unref (file);
333
archive_path = cd_cache_uri_to_archive (uri);
364
if (cd_cache_check_archive (cache, local, error) == FALSE) {
365
cd_cache_free (cache);
335
369
cache->device = local;
337
cache->iso_file = g_file_new_for_uri (archive_path);
338
g_free (archive_path);
340
mount = g_file_find_enclosing_mount (cache->iso_file, NULL, &err);
341
if (mount == NULL && g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED)) {
342
CdCacheCallbackData data;
344
memset (&data, 0, sizeof(data));
346
g_file_mount_enclosing_volume (cache->iso_file,
350
(GAsyncReadyCallback) cd_cache_mount_archive_callback,
352
while (!data.called) g_main_context_iteration (NULL, TRUE);
356
g_propagate_error (error, data.error);
358
g_set_error (error, TOTEM_PL_PARSER_ERROR, TOTEM_PL_PARSER_ERROR_MOUNT_FAILED,
359
_("Failed to mount %s."), cache->device);
361
cd_cache_free (cache);
365
} else if (mount == NULL) {
366
cd_cache_free (cache);
369
g_object_unref (mount);
372
cache->content_types = g_content_type_guess_for_tree (cache->iso_file);
373
cache->mountpoint = g_file_get_path (cache->iso_file);
374
cache->self_mounted = self_mounted;
375
cache->mounted = TRUE;
370
cache->self_mounted = FALSE;
371
cache->mounted = FALSE;
571
567
/* We can't have audio CDs on disc, yet */
572
if (cache->is_media == FALSE) {
568
if (cache->is_media == FALSE)
573
569
return MEDIA_TYPE_DATA;
575
570
if (!cd_cache_open_device (cache, error))
576
571
return MEDIA_TYPE_ERROR;
578
572
if (cd_cache_has_content_type (cache, "x-content/audio-cdda") != FALSE)
579
573
return MEDIA_TYPE_CDDA;