find less than 1 KB file in fat32

how can i access to the root directory etry with c++ code.
there is a attribute in the directory attributes that size are specified there.
how can i access to the directory attributes . plz help me.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <iostream>
#include "KLibIncUse.h"

using namespace std;

const _fsize_t  _1K = 1 * 1024;


void FuncFndSizeLessThan1k(const KStr & strDir, const _finddata_t & fi, void * pvParam);


int main(int argc, char * argv[])
{
   KDirTraverser dirTrv;
   dirTrv.SetFileSpec("*.*");
   dirTrv.SetFileExecInfoFunc(FuncFndSizeLessThan1k, NULL);
   dirTrv.SetRecurtSubDirs(true);         // process sub directories as well
   dirTrv.Execute();

   return 0;
}


void FuncFndSizeLessThan1k(const KStr & strDir, const _finddata_t & fi, void * pvParam)
{
   if (fi.size < _1K)
   {
      cout << "dir [" << strDir.sz() << "],  fname [" << fi.name << "]" << endl;
   }
}


This solution uses Kahless_9 framework which you can download from: www.shankodev.com download page. The Linux version doesn't allow function pointer passing _finddata_t as this is windows specific, but can still use same code with function pointer to string based filename and then use KFileIO::FileSize on respective file.


Last edited on
Topic archived. No new replies allowed.