Correctly compute directoty size on Joliet and ISO-9660:1999 trees.

This commit is contained in:
Vreixo Formoso 2008-08-19 03:46:04 +02:00
parent ce0949a585
commit f9e15054db
2 changed files with 22 additions and 12 deletions

View File

@ -549,8 +549,12 @@ size_t calc_dir_size(Ecma119Image *t, Iso1999Node *dir)
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;
Iso1999Node *child = dir->info.dir->children[i]; Iso1999Node *child = dir->info.dir->children[i];
size_t dirent_len = calc_dirent_len(t, child); size_t dirent_len = calc_dirent_len(t, child);
nsections = (child->type == ISO1999_FILE) ? child->info.file->nsections : 1;
for (section = 0; section < nsections; ++section) {
remaining = BLOCK_SIZE - (len % BLOCK_SIZE); remaining = BLOCK_SIZE - (len % BLOCK_SIZE);
if (dirent_len > remaining) { if (dirent_len > remaining) {
/* child directory entry doesn't fit on block */ /* child directory entry doesn't fit on block */
@ -559,6 +563,7 @@ size_t calc_dir_size(Ecma119Image *t, Iso1999Node *dir)
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

View File

@ -580,8 +580,12 @@ size_t calc_dir_size(Ecma119Image *t, JolietNode *dir)
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;
JolietNode *child = dir->info.dir->children[i]; JolietNode *child = dir->info.dir->children[i];
size_t dirent_len = calc_dirent_len(t, child); size_t dirent_len = calc_dirent_len(t, child);
nsections = (child->type == JOLIET_FILE) ? child->info.file->nsections : 1;
for (section = 0; section < nsections; ++section) {
remaining = BLOCK_SIZE - (len % BLOCK_SIZE); remaining = BLOCK_SIZE - (len % BLOCK_SIZE);
if (dirent_len > remaining) { if (dirent_len > remaining) {
/* child directory entry doesn't fit on block */ /* child directory entry doesn't fit on block */
@ -590,6 +594,7 @@ size_t calc_dir_size(Ecma119Image *t, JolietNode *dir)
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