directorys auslesen!
-
hallo,
ich suche eine möglichkeit in C / C++, die gesammte Festplatte nach einer bestimmten .ini datei zu durchsuchen, jedoch weiß ich nicht mit welchem command man directorys und sub directorys auslesen kann!
-
Direkt mit der jeweiligen API des Betriebssystems ist das möglich, welches benützt du denn?
Auf der anderen Seite kannst du auch boost::filesystem (http://www.boost.org) verwenden, bzw. schau dir mal DirStream von HumeSikkins an (http://bens.c-plusplus.info) - allerdings weiß ich nicht, ob man mit DirStream auch Dateien suchen kann.
MfG SideWinder
-
ok danke, benutze windows
von boost hab ich schonmal gehört, werde ich mir einmal angucken
was ist denn API?
-
also xp
-
#include "stdafx.h" #include <string.h> #include <windows.h> #include <stdio.h> #include <string> using std::string; using namespace std; int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind = INVALID_HANDLE_VALUE; char* DirSpec = "C:\\*"; DWORD dwError; hFind = FindFirstFile(DirSpec, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { printf ("Invalid file handle. Error is %u\n", GetLastError()); return (-1); } else { string path = DirSpec; path = path.substr(0, path.length()-1); while (FindNextFile(hFind, &FindFileData) != 0) { char* filename = FindFileData.cFileName; string s = filename; if (s.find(".int", 0) != string::npos) { string file = path + filename; cout << file << endl; } } dwError = GetLastError(); FindClose(hFind); if (dwError != ERROR_NO_MORE_FILES) { printf ("%u\n", dwError); return (-1); } } return (0); }