Skip to content

Commit 9c6cfa5

Browse files
committed
diskbuilder: Fix issue with many long filenames in directory
1 parent d46be4b commit 9c6cfa5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

diskimagebuild/writer.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,17 @@ void fill_unused(std::vector<cl_dir>& ents, int num)
163163
ent.cluster_hi = 0;
164164
ent.cluster_lo = 0;
165165
ent.filesize = 0;
166-
while (num--) ents.push_back(ent);
166+
while (num-- > 0) ents.push_back(ent);
167167
}
168168
void mod16_test(std::vector<cl_dir>& ents, int& mod16, int long_entries)
169169
{
170170
// if longname is overshooting sector
171-
if (mod16 + long_entries + 1 > ENTS_PER_SECT) {
171+
int x = mod16 % ENTS_PER_SECT;
172+
if (x + long_entries + 1 > ENTS_PER_SECT) {
172173
// fill remainder of sector with unused entries
173-
fill_unused(ents, ENTS_PER_SECT - mod16);
174-
mod16 = 0;
174+
x = ENTS_PER_SECT - x;
175+
fill_unused(ents, x);
176+
mod16 += x;
175177
}
176178
mod16 += long_entries;
177179
}
@@ -266,7 +268,7 @@ long Dir::write(FileSys& fsys, FILE* file, long pos, long parent)
266268

267269
long File::write(FileSys&, FILE* file, long pos) const
268270
{
269-
printf("writing file to %ld with size %u\n", pos, this->size);
271+
//printf("writing file to %ld with size %u\n", pos, this->size);
270272
fseek(file, pos, SEEK_SET);
271273
int count = fwrite(data.get(), this->size, 1, file);
272274
assert(count == 1);

0 commit comments

Comments
 (0)