snippets / liste

All snippets tagged liste (2)

  1. Changer du texte dans des fichiers recursivement

    un script en python pour remplacer du texte recursivement dans des fichiers.

     1 import os
    2 liste = os.listdir('c:/repertoire')
    3 for fichiers in liste :
    4 if os.path.isfile(fichiers):
    5 fichier=open(fichiers, "r")
    6 contenu=fichier.read()
    7 contenu = contenu.replace('\n<\?','<?')
    8 contenu = contenu.replace('\n\?>','?>')
    9 else:
    10 liste.append(os.listdir(fichiers))
  2. [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...