-
May 18th, 2020, 05:09 AM
#1
MSDN documentation unclear ?
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 ...
-
May 18th, 2020, 06:20 AM
#2
Re: MSDN documentation unclear ?
Why can't you just use the assigned drive letter when the USB drive is plugged in and the the usual FindFirst/FindNext WIN32 API's or C++17 directory_iterator()?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 18th, 2020, 06:27 AM
#3
Re: MSDN documentation unclear ?
If you really need to do this the hard way, have a look at https://rshullic.wordpress.com/2010/...ory-structure/ which contains sample c code to do this.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 18th, 2020, 07:39 AM
#4
Re: MSDN documentation unclear ?
Originally Posted by 2kaud
Why can't you just use the assigned drive letter when the USB drive is plugged in and the the usual FindFirst/FindNext WIN32 API's or C++17 directory_iterator()?
In the end, I intend to read even the deleted files/directory, and FindFirst/FindNext doesn't have such feature, as far as I know.
-
May 18th, 2020, 07:53 AM
#5
Re: MSDN documentation unclear ?
Originally Posted by mesajflaviu
In the end, I intend to read even the deleted files/directory, and FindFirst/FindNext doesn't have such feature, as far as I know.
Ah. No, FindFirst() et al doesn't provide info on deleted items. Then the example in my post #3 could be useful.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 18th, 2020, 09:10 AM
#6
Re: MSDN documentation unclear ?
Originally Posted by 2kaud
Ah. No, FindFirst() et al doesn't provide info on deleted items. Then the example in my post #3 could be useful.
Yes, that's right, look very promising that post ... thank you !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|