snippets / scanner

All snippets tagged scanner (1)

  1. [Windows|STL] scanner un repertoire récursivement

    Rempli la liste des fichiers d'un repertoire et de ses sous-repertoire récusivement.

     1 void scan( const std::wstring& path, const std::wstring& filter, std::vector<std::wstring> &list )
    2 {
    3 WIN32_FIND_DATA FindFileData;
    4 HANDLE hFind;
    5
    6 std::wstring tmp = path + filter;
    7 hFind = ::FindFirstFile( tmp.c_str(), &FindFileData);
    8
    9 if ( hFind == INVALID_HANDLE_VALUE )
    10 {
    11 throw Exception();
    12 return ;
    13 }
    14
    15 do
    16 {
    17 std::wstring filename = FindFileData.cFileName;
    18 if ( filename == TEXT(".") )
    19 continue;
    20 if ( filename == TEXT("..") )
    21 continue;
    22 if ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
    23 scan( path + filename + TEXT("\\"), filter, list );
    24 else
    25 list.push_back( path + filename );
    26
    27 } while ( ::FindNextFile(hFind, &FindFileData) != 0 );
    28 }
    29
    30 //Utilisation
    31 std::map<std::wstring> list;
    32 scan( TEXT("C:\\"), TEXT("*"), list ) ;
    Posted by themadmax to c++ windows liste scanner dir ... saved by 1 person ... 0 comments ... 1 year, 1 month
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...