I want to get the FAT32 properties of some file. I already figured out how FAT32 stores them and wrote a structure for storing them. But the question arose: how to get them?

At first I wanted to do this:

FILE* in = fopen("H:\\test.txt", "rb"); 

But fopen() deprives us of this information.

Is it possible to get FAT32 file properties in any way?

    1 answer 1

    C ++ abstracts file system properties from you, so you have to use system-specific functions.

    For Windows, the information you need is in the WIN32_FIND_DATA structure. It can be obtained, for example, with the help of FindFirstFile .

    Code from MSDN:

     #include <windows.h> WIN32_FIND_DATA FindFileData; HANDLE hFind = FindFirstFile(filename, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { // обработать ошибку return; } else { // можно пользоваться // не забудьте в конце: FindClose(hFind); } 

    For the Linux platform, stat (2) provides similar information.

     #include <sys/types.h> #include <sys/stat.h> struct stat sb; if (stat(argv[1], &sb) == -1) { // обработать ошибку return; } else { // можно пользоваться } 
    • Thank you very much. I just tried to implement everything by running on the Fat table - Valentin Chikunov
    • You are welcome! Please note this code will work on NTFS. - VladD
    • 3
      @ Valentin Chikunov if you want to disassemble FAT / NTFS / other - CreateFile ('\\. \ PhysicalDrive0', ...) in Windows. - Vladimir Martyanov