Compute correctly directory size.

This commit is contained in:
Vreixo Formoso 2008-08-19 03:31:50 +02:00
parent 126e60741e
commit ce0949a585

View File

@ -117,9 +117,13 @@ size_t calc_dir_size(Ecma119Image *t, Ecma119Node *dir, size_t *ce)
for (i = 0; i < dir->info.dir->nchildren; ++i) { for (i = 0; i < dir->info.dir->nchildren; ++i) {
size_t remaining; size_t remaining;
int section, nsections;
Ecma119Node *child = dir->info.dir->children[i]; Ecma119Node *child = dir->info.dir->children[i];
size_t dirent_len = calc_dirent_len(t, child); size_t dirent_len = calc_dirent_len(t, child);
if (t->rockridge) {
nsections = (child->type == ECMA119_FILE) ? child->info.file->nsections : 1;
for (section = 0; section < nsections; ++section) {
if (t->rockridge && section == nsections - 1) {
dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len, &ce_len); dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len, &ce_len);
*ce += ce_len; *ce += ce_len;
} }
@ -131,6 +135,7 @@ size_t calc_dir_size(Ecma119Image *t, Ecma119Node *dir, size_t *ce)
len += dirent_len; len += dirent_len;
} }
} }
}
/* /*
* The size of a dir is always a multiple of block size, as we must add * The size of a dir is always a multiple of block size, as we must add
@ -459,8 +464,11 @@ int write_one_dir(Ecma119Image *t, Ecma119Node *dir)
len += 2; len += 2;
} }
nsections = (child->type == ECMA119_FILE) ? child->info.file->nsections : 1;
for (section = 0; section < nsections; ++section) {
/* get the SUSP fields if rockridge is enabled */ /* get the SUSP fields if rockridge is enabled */
if (t->rockridge) { if (t->rockridge && section == nsections - 1) {
ret = rrip_get_susp_fields(t, child, 0, 255 - len, &info); ret = rrip_get_susp_fields(t, child, 0, 255 - len, &info);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
@ -468,9 +476,6 @@ int write_one_dir(Ecma119Image *t, Ecma119Node *dir)
len += info.suf_len; len += info.suf_len;
} }
nsections = (child->type == ECMA119_FILE) ? child->info.file->nsections : 1;
for (section = 0; section < nsections; ++section) {
if ( (buf + len - buffer) > BLOCK_SIZE) { if ( (buf + len - buffer) > BLOCK_SIZE) {
/* dir doesn't fit in current block */ /* dir doesn't fit in current block */
ret = iso_write(t, buffer, BLOCK_SIZE); ret = iso_write(t, buffer, BLOCK_SIZE);