394
397
return BRASERO_ISO_ERROR;
400
static BraseroIsoResult
401
brasero_iso9660_get_first_directory_record (BraseroIsoCtx *ctx,
402
BraseroIsoDirRec **record,
405
BraseroIsoResult result;
407
BRASERO_BURN_LOG ("Reading directory record");
409
result = brasero_iso9660_seek (ctx, address);
410
if (result != BRASERO_ISO_OK)
411
return BRASERO_ISO_ERROR;
414
result = brasero_iso9660_next_record (ctx, record);
415
if (result != BRASERO_ISO_OK)
416
return BRASERO_ISO_ERROR;
418
return BRASERO_ISO_OK;
397
421
static BraseroVolFile *
398
422
brasero_iso9660_read_file_record (BraseroIsoCtx *ctx,
399
423
BraseroIsoDirRec *record,
475
508
address = brasero_iso9660_get_733_val (record->address);
510
BRASERO_BURN_LOG ("New directory %s with susp area", directory->name);
512
/* if this directory has a "RE" susp entry then drop it; it's
513
* not at the right place in the Rock Ridge file hierarchy. It
514
* will probably be skipped */
515
if (susp_ctx.has_RE) {
516
BRASERO_BURN_LOG ("Rock Ridge relocated directory. Skipping entry.");
517
directory->relocated = TRUE;
520
if (susp_ctx.rr_name) {
521
BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx.rr_name);
522
directory->rr_name = susp_ctx.rr_name;
523
susp_ctx.rr_name = NULL;
526
brasero_susp_ctx_clean (&susp_ctx);
478
529
address = brasero_iso9660_get_733_val (record->address);
480
directory = brasero_iso9660_read_directory_records (ctx, address);
482
if (ctx->has_susp && ctx->has_RR)
483
brasero_susp_ctx_clean (&susp_ctx);
488
directory->name = g_new0 (gchar, record->id_size + 1);
489
memcpy (directory->name, record->id, record->id_size);
491
if (!ctx->has_susp || !ctx->has_RR) {
492
BRASERO_BURN_LOG ("New directory %s", directory->name);
496
BRASERO_BURN_LOG ("New directory %s with susp area", directory->name);
498
/* if this directory has a "RE" susp entry then drop it; it's not at the
499
* right place in the Rock Ridge file hierarchy. */
500
if (susp_ctx.has_RE) {
501
BRASERO_BURN_LOG ("Rock Ridge relocated directory. Skipping entry.");
502
directory->relocated = TRUE;
505
if (susp_ctx.rr_name) {
506
BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx.rr_name);
507
directory->rr_name = susp_ctx.rr_name;
508
susp_ctx.rr_name = NULL;
511
brasero_susp_ctx_clean (&susp_ctx);
531
/* load contents if recursive */
535
brasero_iso9660_get_first_directory_record (ctx,
538
children = brasero_iso9660_load_directory_records (ctx,
542
if (!children && ctx->error) {
543
brasero_volume_file_free (directory);
544
if (ctx->has_susp && ctx->has_RR)
545
brasero_susp_ctx_clean (&susp_ctx);
550
directory->isdir_loaded = TRUE;
551
directory->specific.dir.children = children;
553
else /* store the address of contents for later use */
554
directory->specific.dir.address = address;
556
BRASERO_BURN_LOG ("New directory %s", directory->name);
512
557
return directory;
515
static BraseroVolFile *
516
brasero_iso9660_read_directory_records (BraseroIsoCtx *ctx, gint address)
561
brasero_iso9660_load_directory_records (BraseroIsoCtx *ctx,
562
BraseroVolFile *parent,
563
BraseroIsoDirRec *record,
520
568
gint max_record_size;
521
569
BraseroVolFile *entry;
570
GList *children = NULL;
522
571
BraseroIsoResult result;
523
BraseroIsoDirRec *record;
524
572
GSList *directories = NULL;
525
BraseroVolFile *parent = NULL;
527
BRASERO_BURN_LOG ("Reading directory record");
529
result = brasero_iso9660_seek (ctx, address);
530
if (result != BRASERO_ISO_OK)
534
result = brasero_iso9660_next_record (ctx, &record);
535
if (result != BRASERO_ISO_OK)
538
/* look for "SP" SUSP if it's root directory */
540
BraseroSuspCtx susp_ctx;
544
susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
545
brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len);
547
ctx->has_susp = susp_ctx.has_SP;
548
ctx->has_RR = susp_ctx.has_RockRidge;
549
ctx->susp_skip = susp_ctx.skip;
550
ctx->is_root = FALSE;
553
BRASERO_BURN_LOG ("File system supports system use sharing protocol");
556
BRASERO_BURN_LOG ("File system has Rock Ridge extension");
558
brasero_susp_ctx_clean (&susp_ctx);
561
574
max_record_size = brasero_iso9660_get_733_val (record->file_size);
562
575
max_block = ISO9660_BYTES_TO_BLOCKS (max_record_size);
681
692
entry->parent = parent;
682
parent->specific.dir.children = g_list_prepend (parent->specific.dir.children, entry);
693
children = g_list_prepend (children, entry);
684
695
g_slist_foreach (directories, (GFunc) g_free, NULL);
685
696
g_slist_free (directories);
702
g_list_foreach (children, (GFunc) brasero_volume_file_free, NULL);
703
g_list_free (children);
691
705
g_slist_foreach (directories, (GFunc) g_free, NULL);
692
706
g_slist_free (directories);
694
brasero_volume_file_free (parent);
712
brasero_iso9660_check_SUSP_RR_use (BraseroIsoCtx *ctx,
713
BraseroIsoDirRec *record)
715
BraseroSuspCtx susp_ctx;
719
susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
720
brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len);
722
ctx->has_susp = susp_ctx.has_SP;
723
ctx->has_RR = susp_ctx.has_RockRidge;
724
ctx->susp_skip = susp_ctx.skip;
725
ctx->is_root = FALSE;
728
BRASERO_BURN_LOG ("File system supports system use sharing protocol");
731
BRASERO_BURN_LOG ("File system has Rock Ridge extension");
733
brasero_susp_ctx_clean (&susp_ctx);
699
738
brasero_iso9660_ctx_init (BraseroIsoCtx *ctx, BraseroVolSrc *vol)
714
755
BraseroIsoPrimary *primary;
756
BraseroIsoDirRec *record;
715
757
BraseroVolFile *volfile;
716
758
BraseroIsoDirRec *root;
717
759
BraseroIsoCtx ctx;
720
763
primary = (BraseroIsoPrimary *) block;
721
764
root = primary->root_rec;
767
address = brasero_iso9660_get_733_val (root->address);
723
768
brasero_iso9660_ctx_init (&ctx, vol);
725
address = brasero_iso9660_get_733_val (root->address);
727
BRASERO_BURN_LOG ("Reading root directory record at %i", address);
728
volfile = brasero_iso9660_read_directory_records (&ctx, address);
769
brasero_iso9660_get_first_directory_record (&ctx, &record, address);
770
brasero_iso9660_check_SUSP_RR_use (&ctx, record);
772
/* create volume file */
773
volfile = g_new0 (BraseroVolFile, 1);
774
volfile->isdir = TRUE;
775
volfile->isdir_loaded = FALSE;
777
children = brasero_iso9660_load_directory_records (&ctx,
781
volfile->specific.dir.children = children;
730
783
if (ctx.spare_record)
731
784
g_free (ctx.spare_record);
1052
brasero_iso9660_get_directory_contents (BraseroVolSrc *vol,
1053
const gchar *vol_desc,
1057
BraseroIsoDirRec *record = NULL;
1058
BraseroIsoPrimary *primary;
1059
BraseroIsoDirRec *root;
1063
/* Check root "." for use of RR and things like that */
1064
primary = (BraseroIsoPrimary *) vol_desc;
1065
root = primary->root_rec;
1067
brasero_iso9660_ctx_init (&ctx, vol);
1068
brasero_iso9660_get_first_directory_record (&ctx,
1070
brasero_iso9660_get_733_val (root->address));
1071
brasero_iso9660_check_SUSP_RR_use (&ctx, record);
1073
/* Seek up to the contents of the directory */
1075
brasero_iso9660_get_first_directory_record (&ctx,
1080
children = brasero_iso9660_load_directory_records (&ctx,
1084
if (ctx.error && error)
1085
g_propagate_error (error, ctx.error);