1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- void isZombie(const char *findPath = ".", const char *outFile = "./zombie.list") {
- char *fName;
- std::cout << "Open directory " << findPath << "... ";
- void *pDir = gSystem->OpenDirectory(findPath);
- if (!pDir) {
- std::cout << "[FAIL]" << std::endl
- << "\texiting..." << std::endl;
- return;
- }
- std::cout << "[OK]" << std::endl;
- std::cout << "Open file " << outFile << " for writing... ";
- FILE *fOut = fopen(outFile, "w");
- if (!fOut) {
- std::cout << "[FAIL]" << std::endl
- << "\texiting..." << std::endl;
- return;
- }
- std::cout << "[OK]" << std::endl;
-
- TString fullPath("");
- unsigned int nZombies = 0;
- while (fName = (char *)gSystem->GetDirEntry(pDir)) {
- if (!strstr(fName, ".root")) continue;
- fullPath = findPath;
- fullPath += '/';
- fullPath += fName;
- TFile file(fullPath, "READ");
- if (file.IsOpen()) {
- fullPath += '\n';
- std::cout << "working with file " << fName << std::endl;
- if (file.IsZombie() || file.TestBit(TFile::kRecovered)) {
- const char *chFullPath = (const char *)fullPath;
- std::cout << "zombie spotted: " << chFullPath;
- nZombies++;
- fputs(chFullPath, fOut);
- }
- }
- }
- std::cout << "Total zombies: " << nZombies << std::endl;
-
- fclose(fOut);
- }
|