4
440gtx
I would like to represent used/free clusters on a disk drive in a
standard container. Pardon platform specifics, but the cluster data
comes from a POD header followed by the cluster bitmap as defined by
FSCTL_GET_VOLUME_BITMAP. One choice is to create an empty vector
<bool> and manually copy the bits. Since there can be billions of
clusters, this is very inefficient in terms of needing double the
memory and then the time to copy billions of bits:
vector <bool> bitmap;
VOLUME_BITMAP_BUFFER *out = (VOLUME_BITMAP_BUFFER *)malloc(out_len);
…call ioctl…
bitmap.resize(out->BitmapSize.QuadPart);
for (vector <bool>::size_type i = 0; i < bitmap.size(); ++i)
bitmap = (out->Buffer[i/8] >> (i % 8)) & 1;
Are there more appropriate ways?
standard container. Pardon platform specifics, but the cluster data
comes from a POD header followed by the cluster bitmap as defined by
FSCTL_GET_VOLUME_BITMAP. One choice is to create an empty vector
<bool> and manually copy the bits. Since there can be billions of
clusters, this is very inefficient in terms of needing double the
memory and then the time to copy billions of bits:
vector <bool> bitmap;
VOLUME_BITMAP_BUFFER *out = (VOLUME_BITMAP_BUFFER *)malloc(out_len);
…call ioctl…
bitmap.resize(out->BitmapSize.QuadPart);
for (vector <bool>::size_type i = 0; i < bitmap.size(); ++i)
bitmap = (out->Buffer[i/8] >> (i % 8)) & 1;
Are there more appropriate ways?