Pergunta

I want to create a tree of the CD content in memory using structures and std::vector, for both directories and files. I won't scan the files in detail, i'm only interested if they are directories or regular files.

What is the best and fastest approach for this ? Would a recursive scan make the CD unit head jump around the drive looking for files/folder ?

I want to reduce CD unit head jumps and to make it as fast as possible. BTW: I'm using UNIX and C/C++.

Foi útil?

Solução

According to the ISO 9660 specification:

Contained within the primary volume descriptor is the root directory record describing the location of the contiguous root directory. (As in UNIX, directories appear as files for the operating system?s special use). Directory entries are successively stored within this region. Evaluation of the ISO 9660 filenames is begun at this location. The root directory is stored as an extent, or sequential series of sectors, that contains each of the directory entries appearing in the root

Given this information, I would assume that it is fairly unavoidable to have head jumps. You will be starting at this top level directory, say Track X Sector Y, scan to find the first directory to traverse, and moving downward on the disk. So the head will be jumping whenever you dive further into the tree regardless of how your 'diving'. If there was a way to scan the disk based on track and then on sector, that would provide benefit, but I'm unsure how to do that and if its even worth the implementation.

Your decision affects performance not so much on the CDFS, but rather your process overhead. Recursion incurs the overhead of allocating to the stack, and there are memory implications there. But as far as the CDFS, it seems to be less in your control.

I would say go with recursion as it makes logical sense for tree traversals

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top