Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3027

MSDN documentation unclear ?

$
0
0
I am trying to read directories from an EXFAT USB drive. And for this task, I have found here a good documentation: https://docs.microsoft.com/en-us/win...-specification

But seem that is unclear somehow, at least to me.

I have successfully read - Main and Backup Boot Sector Structure Table (https://docs.microsoft.com/en-us/win...ctor-structure), value by value.

And then, I have read - Cluster Heap Structure Table (https://docs.microsoft.com/en-us/win...heap-structure)


Code:

        const int nSize = dwSectorSize * 1 << nSectorsPerClusterShift;
        const int nCount = nClusterCount + 1;
        LONGLONG llPos = nClusterHeapOffset;
        LONGLONG nLimit = nClusterHeapOffset + ((nClusterCount - 1) * nSize);

        for (int i = 0; i < nCount; ++i)
        {
                file.Seek(llPos, CFile::begin);
                arrByte.RemoveAll();
                arrByte.SetSize(nSize);
                UINT nRet = file.Read(arrByte.GetData(), arrByte.GetSize());

                llPos += nSize;
                if (llPos > nLimit)
                        break;
        }

and for every cluster from cluster heap, I retrieved a CByteArray of 32768 bytes. Fine by now. Now, there is another part: Directory Structure Table (https://docs.microsoft.com/en-us/win...tory-structure)

Here I am stuck. I guess I can read the directory (or files) from this cluster, one by one. Theoretically, I should read every cluster from 32 to 32 bytes, according Directory Structure Table, which gave me 1024 (32768 / 32). But in this cluster, I don't know how to consider those bytes in order to have a directory (or file). More over, I don't know how to compute N (for DirectoryEntry[N–1]).

The documentation says: N, the number of DirectoryEntry fields, is the size, in bytes, of the cluster chain which contains the given directory, divided by the size of a DirectoryEntry field, 32 bytes.

From documentation: A cluster chain is a series of clusters which provides space for recording the contents of files, directories, and other file system structures.

Now, how is: "cluster chain which contains the given directory" ? Can you help me a little bit ? I am stuck here for a while, and I don't know how to move on ...

Viewing all articles
Browse latest Browse all 3027

Trending Articles